1+ Param (
2+ [Parameter (Mandatory )]
3+ [string ]$version
4+ )
5+
6+ $profiles = ' win-x64' , ' win-arm64' , ' linux-x64' , ' linux-arm64'
7+
8+ Function Publish-Proj
9+ {
10+ Param (
11+ [Parameter (Mandatory )]
12+ [string ]$DirName
13+ )
14+
15+ Write-Host " Publishing $DirName "
16+ try
17+ {
18+ Push-Location " ./$DirName "
19+ ./ publish.ps1 $profiles
20+ }
21+ finally
22+ {
23+ Pop-Location
24+ }
25+ }
26+
27+ Publish-Proj ' FanScript.Cli'
28+ Publish-Proj ' FanScript.LangServer'
29+
30+ $publishDir = ' Publish'
31+
32+ Write-Host ' Copying files'
33+
34+ New-Item - Path . - Name $publishDir - ItemType " directory" - Force > $null
35+
36+ foreach ($profile in $profiles ) {
37+ New-Item - Path $publishDir - Name $profile - ItemType " directory" - Force
38+ $outDir = " ./$publishDir /$profile "
39+
40+ New-Item - Path $outDir - Name " Cli" - ItemType " directory" - Force > $null
41+ Copy-Item - Path " ./FanScript.Cli/bin/Publish/$profile /*" - Destination " $outDir /Cli"
42+
43+ New-Item - Path $outDir - Name " VSCodeExtension" - ItemType " directory" - Force > $null
44+ $extensionDir = " $outDir /VSCodeExtension"
45+ Copy-Item - Path " ./FanScript.LangServer/bin/Publish/$profile /*" - Destination $extensionDir
46+ Copy-Item - Path " ./VSCodeExtension/*" - Destination $extensionDir - Filter * - Exclude ' node_modules' , ' FanScript.LangServer*' - Recurse - Force
47+
48+ # for some fucking reason -Exclude doesn't work in subdirectories, so the client/node_modules dir has to be deleted
49+ $clientModulesDir = " $extensionDir /client/node_modules"
50+ if (Test-Path $clientModulesDir ) {
51+ Remove-Item - Path $clientModulesDir - Recurse - Force
52+ }
53+ }
54+
55+ Write-Host ' Compressing folders'
56+
57+ foreach ($profile in $profiles ) {
58+ $fromDir = " ./$publishDir /$profile /*"
59+ $toFile = " ./$publishDir /FanScript_$ ( $profile ) _$version .zip"
60+ Write-Host " Comressing $fromDir to $toFile "
61+
62+ Compress-Archive - Path $fromDir - CompressionLevel ' Optimal' - DestinationPath $toFile - Force
63+ }
64+
65+ Write-Host ' Done'
0 commit comments