|
5 | 5 | tags:
|
6 | 6 | - 'v[0-9]*vfs*' # matches "v<number><any characters>vfs<any characters>"
|
7 | 7 |
|
| 8 | +env: |
| 9 | + DO_WIN_CODESIGN: ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME != '' && secrets.WIN_CODESIGN_PASS_SECRET_NAME != '' }} |
| 10 | + DO_WIN_GPGSIGN: ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME != '' && secrets.WIN_GPG_PRIVATE_SECRET_NAME != '' && secrets.WIN_GPG_PASSPHRASE_SECRET_NAME != '' }} |
| 11 | + |
8 | 12 | jobs:
|
9 | 13 | # Check prerequisites for the workflow
|
10 | 14 | 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 }} base64> $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,31 @@ 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: Log in to Azure |
| 222 | + uses: azure/login@v2 |
| 223 | + if: env.DO_WIN_CODESIGN == 'true' |
| 224 | + with: |
| 225 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 226 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 227 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 228 | + - name: Check out repository (for akv-secret Action) |
| 229 | + if: env.DO_WIN_CODESIGN == 'true' |
| 230 | + uses: actions/checkout@v4 |
| 231 | + with: |
| 232 | + path: git |
| 233 | + - name: Download code signing secrets |
| 234 | + id: codesign-secrets |
| 235 | + if: env.DO_WIN_CODESIGN == 'true' |
| 236 | + uses: ./git/.github/actions/akv-secret |
| 237 | + with: |
| 238 | + vault: ${{ secrets.AZURE_VAULT }} |
| 239 | + secrets: | |
| 240 | + ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME }} base64> home/.sig/codesign.p12 |
| 241 | + ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} > home/.sig/codesign.pass |
198 | 242 | - 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 != '' |
| 243 | + if: ${{ steps.codesign-secrets.outcome == 'success' }} |
203 | 244 | shell: bash
|
204 | 245 | 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 | 246 | git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
|
209 | 247 | - name: Retarget auto-update to microsoft/git
|
210 | 248 | shell: bash
|
@@ -237,11 +275,16 @@ jobs:
|
237 | 275 |
|
238 | 276 | b=/usr/src/build-extra &&
|
239 | 277 |
|
240 |
| - sed -i -e '/^ *InstallAutoUpdater();$/a\ |
241 |
| - CustomPostInstall();' \ |
242 |
| - -e '/^ *UninstallAutoUpdater();$/a\ |
243 |
| - CustomPostUninstall();' \ |
244 |
| - $b/installer/install.iss && |
| 278 | + sed -i "# First, find the autoupdater parts in the install/uninstall steps |
| 279 | + /if IsComponentInstalled('autoupdate')/{ |
| 280 | + # slurp in the next two lines, where the call to InstallAutoUpdater()/UninstallAutoUpdater() happens |
| 281 | + N |
| 282 | + N |
| 283 | + # insert the corresponding CustomPostInstall()/CustomPostUninstall() call before that block |
| 284 | + s/^\\([ \t]*\\)\(.*\\)\\(Install\\|Uninstall\\)\\(AutoUpdater\\)/\\1CustomPost\\3();\\n\\1\\2\\3\\4/ |
| 285 | + }" $b/installer/install.iss && |
| 286 | + grep CustomPostInstall $b/installer/install.iss && |
| 287 | + grep CustomPostUninstall $b/installer/install.iss && |
245 | 288 |
|
246 | 289 | cat >>$b/installer/helpers.inc.iss <<\EOF
|
247 | 290 |
|
@@ -304,11 +347,22 @@ jobs:
|
304 | 347 | fi &&
|
305 | 348 | openssl dgst -sha256 artifacts/${{matrix.type.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
|
306 | 349 | - name: Verify that .exe files are code-signed
|
307 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
308 |
| - shell: bash |
| 350 | + if: env.DO_WIN_CODESIGN == 'true' |
| 351 | + shell: pwsh |
309 | 352 | run: |
|
310 |
| - PATH=$PATH:"/c/Program Files (x86)/Windows Kits/10/App Certification Kit/" \ |
311 |
| - signtool verify //pa artifacts/${{matrix.type.fileprefix}}-*.exe |
| 353 | + $ret = 0 |
| 354 | + $files = Get-ChildItem -Path artifacts -Filter "${{matrix.type.fileprefix}}-*.exe" |
| 355 | + foreach ($file in $files) { |
| 356 | + $signature = Get-AuthenticodeSignature -FilePath $file.FullName |
| 357 | + if ($signature.Status -eq 'Valid') { |
| 358 | + Write-Host "[ VALID ] $($file.FullName)" |
| 359 | + } else { |
| 360 | + Write-Host "[INVALID] $($file.FullName)" |
| 361 | + Write-Host " Message: $($signature.StatusMessage)" |
| 362 | + $ret = 1 |
| 363 | + } |
| 364 | + } |
| 365 | + exit $ret |
312 | 366 | - name: Publish ${{matrix.type.name}}-${{matrix.arch.name}}
|
313 | 367 | uses: actions/upload-artifact@v4
|
314 | 368 | with:
|
|
0 commit comments