Skip to content

Commit

Permalink
Create semi-auto publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
fengberd committed Dec 24, 2020
1 parent 64950c4 commit 5544b2f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,5 @@ MigrationBackup/

# protobuf generated stuffs
**/Proto/Out/*.cs

/_publish/**
51 changes: 51 additions & 0 deletions publish_1.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
$release_dir = Resolve-Path "bin\Release";

$version = Get-Content SakuraLibrary\AssemblyBase.cs | Select-String "AssemblyVersion\(`"(.+)`"\)";
$version = $version.Matches[0].Groups[1].Value;

function PrepareDir {
param (
$Dir
)

Remove-Item -Path $Dir -Recurse -ErrorAction SilentlyContinue;
New-Item -Name $Dir -ItemType "directory" -ErrorAction SilentlyContinue;
}

function PrepareVariation {
param (
$Variation
)

$target = "${Variation}_$version";

PrepareDir $target;
Get-ChildItem -Path $release_dir | Where-Object {
$_.Name -eq "$Variation.exe.config" -or (
$_.Extension -match "\.(dll)$" -and
$_.Name -ne "SakuraLibrary.dll" -and
$_.Name -ne "libsodium-64.dll"
) -or (
$_.Extension -match "\.(config)$" -and
$_.Name -notmatch "Launcher\.exe\.config$"
)
} | Copy-Item -Destination $target;
}

New-Item -Name _publish -ItemType "directory" -ErrorAction SilentlyContinue;
Set-Location _publish;

# Prepare 2 variations
PrepareVariation SakuraLauncher
PrepareVariation LegacyLauncher

# Prepare files to be signed
PrepareDir "sign";
Get-ChildItem -Path $release_dir | Where-Object {
$_.Extension -match "\.exe$" -or
$_.Name -eq "SakuraLibrary.dll"
} | Copy-Item -Destination sign;

Copy-Item frpc_windows_386.exe, frpc_windows_amd64.exe sign -ErrorAction SilentlyContinue;

Compress-Archive -Force -CompressionLevel Optimal -Path sign -DestinationPath "sign_$version.zip";
32 changes: 32 additions & 0 deletions publish_2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$version = Get-Content SakuraLibrary\AssemblyBase.cs | Select-String "AssemblyVersion\(`"(.+)`"\)";
$version = $version.Matches[0].Groups[1].Value;

function DeployVariation {
param (
$Variation
)

$target = "${Variation}_$version";

$files = Get-ChildItem -Path "sign" | Where-Object {
$_.Name -eq "$Variation.exe" -or (
$_.Extension -match "\.(exe)$" -and
$_.Name -notmatch "Launcher\.exe$" -and
$_.Name -notmatch "^frpc_"
) -or (
$_.Extension -match "\.(dll)$"
)
};
$files | Copy-Item -Destination $target;
$files | ForEach-Object -Process {
openssl dgst -sign $env:SAKURA_SIGN_KEY -sha256 -out "$target\$($_.Name).sig" $_.FullName
};

Copy-Item "sign\frpc_windows_386.exe" "$target\frpc.exe";
openssl dgst -sign $env:SAKURA_SIGN_KEY -sha256 -out "$target\frpc.exe.sig" "sign\frpc_windows_386.exe";
}

Set-Location _publish;

DeployVariation SakuraLauncher
DeployVariation LegacyLauncher

0 comments on commit 5544b2f

Please sign in to comment.