8
8
9
9
concurrency : ${{ github.ref }}
10
10
11
+ env :
12
+ APPLICATION_NAME : ' adder'
13
+
11
14
jobs :
12
15
create-draft-release :
13
16
runs-on : ubuntu-latest
@@ -59,10 +62,10 @@ jobs:
59
62
- runner : ubuntu-latest
60
63
os : linux
61
64
arch : arm64
62
- - runner : ubuntu -latest
65
+ - runner : windows -latest
63
66
os : windows
64
67
arch : amd64
65
- - runner : ubuntu -latest
68
+ - runner : windows -latest
66
69
os : windows
67
70
arch : arm64
68
71
runs-on : ${{ matrix.runner }}
@@ -75,17 +78,31 @@ jobs:
75
78
id-token : write
76
79
packages : write
77
80
statuses : write
78
- env :
79
- APPLICATION_NAME : ' adder'
80
81
steps :
81
- - run : " echo \" RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
82
+ - name : Set RELEASE_TAG (Windows)
83
+ if : matrix.os == 'windows'
84
+ shell : pwsh
85
+ run : |
86
+ $tagName = $env:GITHUB_REF -replace 'refs/tags/', ''
87
+ echo "RELEASE_TAG=$tagName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
88
+ - name : Set RELEASE_TAG
89
+ if : matrix.os != 'windows'
90
+ run : " echo \" RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
82
91
- uses : actions/checkout@v4
83
92
with :
84
93
fetch-depth : ' 0'
85
94
- uses : actions/setup-go@v5
86
95
with :
87
96
go-version : 1.23.x
97
+ - name : Build binary (Windows)
98
+ if : matrix.os == 'windows'
99
+ shell : pwsh
100
+ run : |
101
+ $env:GOOS = "${{ matrix.os }}"
102
+ $env:GOARCH = "${{ matrix.arch }}"
103
+ make build
88
104
- name : Build binary
105
+ if : matrix.os != 'windows'
89
106
run : GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build
90
107
91
108
# Sign Windows build
@@ -104,32 +121,45 @@ jobs:
104
121
- name : Set up Cloud SDK
105
122
if : ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows' }}
106
123
uses : ' google-github-actions/setup-gcloud@v2'
107
- - name : Sign windows binary
124
+ - name : Sign binary (Windows)
108
125
if : ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows' }}
126
+ shell : pwsh
109
127
run : |
110
- echo "Downloading jsign.jar"
111
- curl -L -o jsign.jar https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar
112
- echo "Verifying jsign.jar checksum"
113
- echo '05ca18d4ab7b8c2183289b5378d32860f0ea0f3bdab1f1b8cae5894fb225fa8a jsign.jar' | sha256sum -c
114
- echo "${{ secrets.CERTIFICATE_CHAIN }}" | base64 --decode > codesign-chain.pem
115
- set +x
116
- _filename=${{ env.APPLICATION_NAME }}
117
- ACCESS_TOKEN=$(gcloud auth print-access-token)
118
- echo "::add-mask::$ACCESS_TOKEN"
119
- java -jar jsign.jar \
120
- --storetype ${{ secrets.CERTIFICATE_STORE_TYPE }} \
121
- --storepass "$ACCESS_TOKEN" \
122
- --keystore ${{ secrets.CERTIFICATE_KEYSTORE }} \
123
- --alias ${{ secrets.CERTIFICATE_KEY_NAME }} \
124
- --certfile codesign-chain.pem \
125
- --tsmode RFC3161 \
126
- --tsaurl http://timestamp.globalsign.com/tsa/r6advanced1 \
127
- ${_filename}
128
- unset ACCESS_TOKEN
129
- set -x
130
- echo "Signed Windows binary: ${_filename}"
131
- echo "Cleaning up certificate chain"
132
- rm -f codesign-chain.pem
128
+ Write-Host "Downloading jsign.jar"
129
+ Invoke-WebRequest -Uri "https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar" -OutFile "jsign.jar"
130
+
131
+ Write-Host "Verifying jsign.jar checksum"
132
+ $expectedHash = "05ca18d4ab7b8c2183289b5378d32860f0ea0f3bdab1f1b8cae5894fb225fa8a"
133
+ $actualHash = (Get-FileHash -Path "jsign.jar" -Algorithm SHA256).Hash.ToLower()
134
+
135
+ if ($actualHash -ne $expectedHash) {
136
+ Write-Error "Hash verification failed for jsign.jar"
137
+ Write-Error "Expected: $expectedHash"
138
+ Write-Error "Actual: $actualHash"
139
+ exit 1
140
+ }
141
+
142
+ [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String("${{ secrets.CERTIFICATE_CHAIN }}")) | Out-File -FilePath "codesign-chain.pem" -Encoding utf8
143
+
144
+ $filename = "${{ env.APPLICATION_NAME }}.exe"
145
+ $ACCESS_TOKEN = & gcloud auth print-access-token
146
+ Write-Host "::add-mask::$ACCESS_TOKEN"
147
+
148
+ java -jar jsign.jar `
149
+ --storetype ${{ secrets.CERTIFICATE_STORE_TYPE }} `
150
+ --storepass "$ACCESS_TOKEN" `
151
+ --keystore ${{ secrets.CERTIFICATE_KEYSTORE }} `
152
+ --alias ${{ secrets.CERTIFICATE_KEY_NAME }} `
153
+ --certfile "codesign-chain.pem" `
154
+ --tsmode RFC3161 `
155
+ --tsaurl "http://timestamp.globalsign.com/tsa/r6advanced1" `
156
+ $filename
157
+
158
+ $ACCESS_TOKEN = $null
159
+
160
+ Write-Host "Signed Windows binary: $filename"
161
+ Write-Host "Cleaning up certificate chain"
162
+ Remove-Item -Path "codesign-chain.pem" -Force
133
163
134
164
# Sign MacOS build
135
165
@@ -177,15 +207,28 @@ jobs:
177
207
ditto -c -k --keepParent "${{ env.APPLICATION_NAME }}.app" "notarization.zip"
178
208
xcrun notarytool submit "notarization.zip" --keychain-profile "notarytool-profile" --wait
179
209
xcrun stapler staple "${{ env.APPLICATION_NAME }}.app"
210
+
211
+ - name : Upload release asset (Windows)
212
+ if : startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows'
213
+ shell : pwsh
214
+ run : |
215
+ $filename = "${{ env.APPLICATION_NAME }}-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}.zip"
216
+ Compress-Archive "${{ env.APPLICATION_NAME }}.exe" "$filename"
217
+ Write-Host "Uploading file: $filename"
218
+ # Upload file using PowerShell
219
+ $headers = @{
220
+ "Authorization" = "token ${{ secrets.GITHUB_TOKEN }}"
221
+ "Content-Type" = "application/octet-stream"
222
+ }
223
+ $uploadUrl = "https://uploads.github.com/repos/${{ github.repository }}/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=$filename"
224
+ Invoke-RestMethod -Uri $uploadUrl -Method Post -Headers $headers -InFile $filename
225
+
180
226
- name : Upload release asset
181
- if : startsWith(github.ref, 'refs/tags/')
227
+ if : startsWith(github.ref, 'refs/tags/') && matrix.os != 'windows'
182
228
run : |
183
- _filename=${{ env.APPLICATION_NAME }}-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}
184
- if [[ "${{ matrix.os }}" == "windows" ]]; then
185
- _filename=${_filename}.exe
186
- fi
187
- if [[ "${{ matrix.os }}" == "windows" || "${{ matrix.os }}" == "linux" || "${{ matrix.os }}" == "freebsd" ]]; then
188
- cp ${{ env.APPLICATION_NAME }} ${_filename}
229
+ _filename=${{ env.APPLICATION_NAME }}-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
230
+ if [[ "${{ matrix.os }}" != "windows" ]]; then
231
+ tar czf ${_filename} ${{ env.APPLICATION_NAME }}
189
232
fi
190
233
if [[ "${{ matrix.os }}" == "darwin" ]]; then
191
234
_filename=${{ env.APPLICATION_NAME }}-${{ env.RELEASE_TAG }}-${{ matrix.os }}-${{ matrix.arch }}.zip
@@ -197,7 +240,14 @@ jobs:
197
240
--data-binary @${_filename} \
198
241
https://uploads.github.com/repos/${{ github.repository_owner }}/adder/releases/${{ needs.create-draft-release.outputs.RELEASE_ID }}/assets?name=${_filename}
199
242
243
+ - name : Attest binary (Windows)
244
+ if : startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows'
245
+ uses : actions/attest-build-provenance@v2
246
+ with :
247
+ subject-path : ' ${{ env.APPLICATION_NAME }}.exe'
248
+
200
249
- name : Attest binary
250
+ if : startsWith(github.ref, 'refs/tags/') && matrix.os != 'windows'
201
251
uses : actions/attest-build-provenance@v2
202
252
with :
203
253
subject-path : ' ${{ env.APPLICATION_NAME }}'
0 commit comments