44 push :
55 tags :
66 - ' *'
7+ workflow_dispatch :
8+ inputs :
9+ version :
10+ description : ' Version number (e.g. v1.2.3)'
11+ required : true
12+ default : ' v1.2.3'
713
814permissions :
915 contents : write
1016
1117jobs :
12- build :
18+ release :
1319 runs-on : windows-latest
1420
1521 steps :
@@ -20,42 +26,83 @@ jobs:
2026 with :
2127 dotnet-version : ' 8.0.x'
2228
29+ # Necessary for signing Windows binaries.
30+ - name : Setup Java
31+ uses : actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # v4.7.0
32+ with :
33+ distribution : " zulu"
34+ java-version : " 11.0"
35+
2336 - name : Get version from tag
2437 id : version
2538 shell : pwsh
2639 run : |
27- $tag = $env:GITHUB_REF -replace 'refs/tags/',''
40+ $ErrorActionPreference = "Stop"
41+ if ($env:INPUT_VERSION) {
42+ $tag = $env:INPUT_VERSION
43+ } else {
44+ $tag = $env:GITHUB_REF -replace 'refs/tags/',''
45+ }
2846 if ($tag -notmatch '^v\d+\.\d+\.\d+$') {
29- throw "Tag must be in format v1.2.3"
47+ throw "Version must be in format v1.2.3, got $tag "
3048 }
3149 $version = $tag -replace '^v',''
32- $assemblyVersion = "$version.0"
33- echo "VERSION=$version" >> $env:GITHUB_OUTPUT
34- echo "ASSEMBLY_VERSION=$assemblyVersion" >> $env:GITHUB_OUTPUT
50+ $assemblyVersion = "$($version).0"
51+ Add-Content -Path $env:GITHUB_OUTPUT -Value "VERSION=$version"
52+ Add-Content -Path $env:GITHUB_OUTPUT -Value "ASSEMBLY_VERSION=$assemblyVersion"
53+ Write-Host "Version: $version"
54+ Write-Host "Assembly version: $assemblyVersion"
55+ env :
56+ INPUT_VERSION : ${{ inputs.version }}
3557
36- - name : Build and publish x64
37- run : |
38- dotnet publish src/App/App.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64
39- dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64
58+ # Setup GCloud for signing Windows binaries.
59+ - name : Authenticate to Google Cloud
60+ id : gcloud_auth
61+ uses : google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
62+ with :
63+ workload_identity_provider : ${{ secrets.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
64+ service_account : ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
65+ token_format : " access_token"
4066
41- - name : Build and publish arm64
42- run : |
43- dotnet publish src/App/App.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64
44- dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64
67+ - name : Setup GCloud SDK
68+ uses : google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
4569
46- - name : Create ZIP archives
70+ - name : scripts/Release.ps1
71+ id : release
4772 shell : pwsh
4873 run : |
49- Compress-Archive -Path "publish/x64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip"
50- Compress-Archive -Path "publish/arm64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip"
74+ $ErrorActionPreference = "Stop"
5175
52- - name : Create Release
53- uses : softprops/action-gh-release@v1
76+ $env:EV_CERTIFICATE_PATH = Join-Path $env:TEMP "ev_cert.pem"
77+ $env:JSIGN_PATH = Join-Path $env:TEMP "jsign-6.0.jar"
78+ Invoke-WebRequest -Uri "https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar" -OutFile $env:JSIGN_PATH
79+
80+ & ./scripts/Release.ps1 `
81+ -version ${{ steps.version.outputs.VERSION }} `
82+ -assemblyVersion ${{ steps.version.outputs.ASSEMBLY_VERSION }}
83+ if ($LASTEXITCODE -ne 0) { throw "Failed to publish" }
84+ env :
85+ EV_SIGNING_CERT : ${{ secrets.EV_SIGNING_CERT }}
86+ EV_KEYSTORE : ${{ secrets.EV_KEYSTORE }}
87+ EV_KEY : ${{ secrets.EV_KEY }}
88+ EV_TSA_URL : ${{ secrets.EV_TSA_URL }}
89+ GCLOUD_ACCESS_TOKEN : ${{ steps.gcloud_auth.outputs.access_token }}
90+
91+ - name : Upload artifact
92+ uses : actions/upload-artifact@v4
93+ with :
94+ name : publish
95+ path : .\publish\
96+
97+ - name : Create release
98+ uses : softprops/action-gh-release@v2
99+ if : startsWith(github.ref, 'refs/tags/')
54100 with :
55- files : |
56- ./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip
57- ./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip
58101 name : Release ${{ steps.version.outputs.VERSION }}
59102 generate_release_notes : true
103+ # We currently only release the bootstrappers, not the MSIs.
104+ files : |
105+ ${{ steps.release.outputs.X64_OUTPUT_PATH }}
106+ ${{ steps.release.outputs.ARM64_OUTPUT_PATH }}
60107 env :
61108 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments