Skip to content

Commit d70e07d

Browse files
feat: add signing for windows binaries (#304)
1 parent 6f12c89 commit d70e07d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,48 @@ jobs:
6161
- uses: actions/setup-go@v5
6262
with:
6363
go-version: 1.22.x
64+
- name: Set up Java
65+
uses: actions/setup-java@v4
66+
with:
67+
java-version: 17
68+
distribution: 'temurin'
6469
- name: Build binary
6570
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} make build
71+
- id: 'auth'
72+
name: Authenticate with Google Cloud
73+
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows'
74+
uses: 'google-github-actions/auth@v2'
75+
with:
76+
credentials_json: '${{ secrets.CERTIFICATE_SA_CREDENTIALS }}'
77+
- name: Set up Cloud SDK
78+
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows'
79+
uses: 'google-github-actions/setup-gcloud@v2'
80+
- name: Sign windows binary
81+
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows'
82+
run: |
83+
echo "Downloading jsign.jar"
84+
curl -L -o jsign.jar https://github.com/ebourg/jsign/releases/download/6.0/jsign-6.0.jar
85+
echo "Verifying jsign.jar checksum"
86+
echo '05ca18d4ab7b8c2183289b5378d32860f0ea0f3bdab1f1b8cae5894fb225fa8a jsign.jar' | sha256sum -c
87+
echo "${{ secrets.CERTIFICATE_CHAIN }}" | base64 --decode > codesign-chain.pem
88+
set +x
89+
_filename=adder
90+
ACCESS_TOKEN=$(gcloud auth print-access-token)
91+
echo "::add-mask::$ACCESS_TOKEN"
92+
java -jar jsign.jar \
93+
--storetype ${{ secrets.CERTIFICATE_STORE_TYPE }} \
94+
--storepass "$ACCESS_TOKEN" \
95+
--keystore ${{ secrets.CERTIFICATE_KEYSTORE }} \
96+
--alias ${{ secrets.CERTIFICATE_KEY_NAME }} \
97+
--certfile codesign-chain.pem \
98+
--tsmode RFC3161 \
99+
--tsaurl http://timestamp.globalsign.com/tsa/r6advanced1 \
100+
${_filename}
101+
unset ACCESS_TOKEN
102+
set -x
103+
echo "Signed Windows binary: ${_filename}"
104+
echo "Cleaning up certificate chain"
105+
rm -f codesign-chain.pem
66106
- name: Upload release asset
67107
if: startsWith(github.ref, 'refs/tags/')
68108
run: |

0 commit comments

Comments
 (0)