|
8 | 8 | permissions:
|
9 | 9 | id-token: write # required for Azure login via OIDC
|
10 | 10 |
|
| 11 | +env: |
| 12 | + DO_WIN_CODESIGN: ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME != '' && secrets.WIN_CODESIGN_PASS_SECRET_NAME != '' }} |
| 13 | + DO_WIN_GPGSIGN: ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME != '' && secrets.WIN_GPG_PRIVATE_SECRET_NAME != '' && secrets.WIN_GPG_PASSPHRASE_SECRET_NAME != '' }} |
| 14 | + |
11 | 15 | jobs:
|
12 | 16 | # Check prerequisites for the workflow
|
13 | 17 | prereqs:
|
@@ -101,43 +105,62 @@ jobs:
|
101 | 105 | git remote add -f origin https://github.com/git-for-windows/git &&
|
102 | 106 | git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} &&
|
103 | 107 | git reset --hard ${tag_name}
|
| 108 | + - name: Log in to Azure |
| 109 | + uses: azure/login@v2 |
| 110 | + with: |
| 111 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 112 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 113 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 114 | + - name: Download code signing secrets |
| 115 | + id: codesign-secrets |
| 116 | + if: env.DO_WIN_CODESIGN == 'true' |
| 117 | + uses: ./.github/actions/akv-secret |
| 118 | + with: |
| 119 | + vault: ${{ secrets.AZURE_VAULT }} |
| 120 | + secrets: | |
| 121 | + ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME }} base64> home/.sig/codesign.p12 |
| 122 | + ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} > home/.sig/codesign.pass |
104 | 123 | - name: Prepare home directory for code-signing
|
105 |
| - env: |
106 |
| - CODESIGN_P12: ${{secrets.CODESIGN_P12}} |
107 |
| - CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} |
108 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
| 124 | + if: ${{ steps.codesign-secrets.outcome == 'success' }} |
109 | 125 | shell: bash
|
110 | 126 | run: |
|
111 |
| - cd home && |
112 |
| - mkdir -p .sig && |
113 |
| - echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >.sig/codesign.p12 && |
114 |
| - echo -n "$CODESIGN_PASS" >.sig/codesign.pass |
115 | 127 | git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
|
| 128 | + - name: Download GPG secrets |
| 129 | + id: gpg-secrets |
| 130 | + if: env.DO_WIN_GPGSIGN == 'true' |
| 131 | + uses: ./.github/actions/akv-secret |
| 132 | + with: |
| 133 | + vault: ${{ secrets.AZURE_VAULT }} |
| 134 | + secrets: | |
| 135 | + ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME }} > $output:keygrip |
| 136 | + ${{ secrets.WIN_GPG_PRIVATE_SECRET_NAME }} > $output:private-key |
| 137 | + ${{ secrets.WIN_GPG_PASSPHRASE_SECRET_NAME }} > $output:passphrase |
116 | 138 | - name: Prepare home directory for GPG signing
|
117 |
| - if: env.GPGKEY != '' |
| 139 | + if: ${{ steps.gpg-secrets.outputs.keygrip != '' && steps.gpg-secrets.outputs.private-key != '' }} |
118 | 140 | shell: bash
|
119 | 141 | run: |
|
120 | 142 | # This section ensures that the identity for the GPG key matches the git user identity, otherwise
|
121 | 143 | # signing will fail
|
122 | 144 |
|
123 |
| - echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import && |
124 |
| - info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && |
| 145 | + # Import the GPG private key |
| 146 | + echo -n '${{ steps.gpg-secrets.outputs.private-key }}' | gpg $GPG_OPTIONS --import && |
| 147 | +
|
| 148 | + info="$(gpg --list-keys --with-colons '${{ steps.gpg-secrets.outputs.keygrip }}' | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && |
125 | 149 | git config --global user.name "${info% <*}" &&
|
126 | 150 | git config --global user.email "<${info#*<}"
|
127 |
| - env: |
128 |
| - GPGKEY: ${{secrets.GPGKEY}} |
129 | 151 | - name: Build mingw-w64-${{matrix.arch.toolchain}}-git
|
130 |
| - env: |
131 |
| - GPGKEY: "${{secrets.GPGKEY}}" |
132 | 152 | shell: bash
|
133 | 153 | run: |
|
134 | 154 | set -x
|
135 | 155 |
|
| 156 | + # Build the GPGKEY variable |
| 157 | + export GPGKEY="${{ steps.gpg-secrets.outputs.keygrip }} --passphrase '${{ steps.gpg-secrets.outputs.passphrase }}' --yes --batch --no-tty --pinentry-mode loopback --digest-algo SHA256" && |
| 158 | +
|
136 | 159 | # Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
|
137 | 160 | printf '#!/bin/sh\n\nexec /${{matrix.arch.mingwprefix}}/bin/git.exe "$@"\n' >/usr/bin/git &&
|
138 | 161 |
|
139 | 162 | sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.name}} --build-src-pkg -o artifacts HEAD &&
|
140 |
| - if test -n "$GPGKEY" |
| 163 | + if test -n "${{ steps.gpg-secrets.outputs.keygrip }}" |
141 | 164 | then
|
142 | 165 | for tar in artifacts/*.tar*
|
143 | 166 | do
|
@@ -195,16 +218,19 @@ jobs:
|
195 | 218 | shell: bash
|
196 | 219 | run: |
|
197 | 220 | git clone --filter=blob:none --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra
|
| 221 | + - name: Download code signing secrets |
| 222 | + id: codesign-secrets |
| 223 | + if: env.DO_WIN_CODESIGN == 'true' |
| 224 | + uses: ./.github/actions/akv-secret |
| 225 | + with: |
| 226 | + vault: ${{ secrets.AZURE_VAULT }} |
| 227 | + secrets: | |
| 228 | + ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME }} base64> home/.sig/codesign.p12 |
| 229 | + ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} > home/.sig/codesign.pass |
198 | 230 | - name: Prepare home directory for code-signing
|
199 |
| - env: |
200 |
| - CODESIGN_P12: ${{secrets.CODESIGN_P12}} |
201 |
| - CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} |
202 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
| 231 | + if: ${{ steps.codesign-secrets.outcome == 'success' }} |
203 | 232 | shell: bash
|
204 | 233 | run: |
|
205 |
| - mkdir -p home/.sig && |
206 |
| - echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 && |
207 |
| - echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass && |
208 | 234 | git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
|
209 | 235 | - name: Retarget auto-update to microsoft/git
|
210 | 236 | shell: bash
|
@@ -313,7 +339,9 @@ jobs:
|
313 | 339 | fi &&
|
314 | 340 | openssl dgst -sha256 artifacts/${{matrix.type.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
|
315 | 341 | - name: Verify that .exe files are code-signed
|
316 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
| 342 | + env: |
| 343 | + DO_CODE_SIGN: ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME != '' }} |
| 344 | + if: env.DO_CODE_SIGN == 'true' |
317 | 345 | shell: bash
|
318 | 346 | run: |
|
319 | 347 | PATH=$PATH:"/c/Program Files (x86)/Windows Kits/10/App Certification Kit/" \
|
|
0 commit comments