|
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:
|
@@ -98,43 +102,62 @@ jobs:
|
98 | 102 | git remote add -f origin https://github.com/git-for-windows/git &&
|
99 | 103 | git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} &&
|
100 | 104 | git reset --hard ${tag_name}
|
| 105 | + - name: Log in to Azure |
| 106 | + uses: azure/login@v2 |
| 107 | + with: |
| 108 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 109 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 110 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 111 | + - name: Download code signing secrets |
| 112 | + id: codesign-secrets |
| 113 | + if: env.DO_WIN_CODESIGN == 'true' |
| 114 | + uses: ./.github/actions/akv-secret |
| 115 | + with: |
| 116 | + vault: ${{ secrets.AZURE_VAULT }} |
| 117 | + secrets: | |
| 118 | + ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME }} base64> home/.sig/codesign.p12 |
| 119 | + ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} > home/.sig/codesign.pass |
101 | 120 | - name: Prepare home directory for code-signing
|
102 |
| - env: |
103 |
| - CODESIGN_P12: ${{secrets.CODESIGN_P12}} |
104 |
| - CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} |
105 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
| 121 | + if: ${{ steps.codesign-secrets.outcome == 'success' }} |
106 | 122 | shell: bash
|
107 | 123 | run: |
|
108 |
| - cd home && |
109 |
| - mkdir -p .sig && |
110 |
| - echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >.sig/codesign.p12 && |
111 |
| - echo -n "$CODESIGN_PASS" >.sig/codesign.pass |
112 | 124 | git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
|
| 125 | + - name: Download GPG secrets |
| 126 | + id: gpg-secrets |
| 127 | + if: env.DO_WIN_GPGSIGN == 'true' |
| 128 | + uses: ./.github/actions/akv-secret |
| 129 | + with: |
| 130 | + vault: ${{ secrets.AZURE_VAULT }} |
| 131 | + secrets: | |
| 132 | + ${{ secrets.WIN_GPG_KEYGRIP_SECRET_NAME }} > $output:keygrip |
| 133 | + ${{ secrets.WIN_GPG_PRIVATE_SECRET_NAME }} base64> $output:private-key |
| 134 | + ${{ secrets.WIN_GPG_PASSPHRASE_SECRET_NAME }} > $output:passphrase |
113 | 135 | - name: Prepare home directory for GPG signing
|
114 |
| - if: env.GPGKEY != '' |
| 136 | + if: ${{ steps.gpg-secrets.outputs.keygrip != '' && steps.gpg-secrets.outputs.private-key != '' }} |
115 | 137 | shell: bash
|
116 | 138 | run: |
|
117 | 139 | # This section ensures that the identity for the GPG key matches the git user identity, otherwise
|
118 | 140 | # signing will fail
|
119 | 141 |
|
120 |
| - echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import && |
121 |
| - info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && |
| 142 | + # Import the GPG private key |
| 143 | + echo -n '${{ steps.gpg-secrets.outputs.private-key }}' | gpg $GPG_OPTIONS --import && |
| 144 | +
|
| 145 | + info="$(gpg --list-keys --with-colons '${{ steps.gpg-secrets.outputs.keygrip }}' | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" && |
122 | 146 | git config --global user.name "${info% <*}" &&
|
123 | 147 | git config --global user.email "<${info#*<}"
|
124 |
| - env: |
125 |
| - GPGKEY: ${{secrets.GPGKEY}} |
126 | 148 | - name: Build mingw-w64-${{matrix.arch.toolchain}}-git
|
127 |
| - env: |
128 |
| - GPGKEY: "${{secrets.GPGKEY}}" |
129 | 149 | shell: bash
|
130 | 150 | run: |
|
131 | 151 | set -x
|
132 | 152 |
|
| 153 | + # Build the GPGKEY variable |
| 154 | + export GPGKEY="${{ steps.gpg-secrets.outputs.keygrip }} --passphrase '${{ steps.gpg-secrets.outputs.passphrase }}' --yes --batch --no-tty --pinentry-mode loopback --digest-algo SHA256" && |
| 155 | +
|
133 | 156 | # Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
|
134 | 157 | printf '#!/bin/sh\n\nexec /${{matrix.arch.mingwprefix}}/bin/git.exe "$@"\n' >/usr/bin/git &&
|
135 | 158 |
|
136 | 159 | sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-${{matrix.arch.name}} --build-src-pkg -o artifacts HEAD &&
|
137 |
| - if test -n "$GPGKEY" |
| 160 | + if test -n "${{ steps.gpg-secrets.outputs.keygrip }}" |
138 | 161 | then
|
139 | 162 | for tar in artifacts/*.tar*
|
140 | 163 | do
|
@@ -192,16 +215,31 @@ jobs:
|
192 | 215 | shell: bash
|
193 | 216 | run: |
|
194 | 217 | git clone --filter=blob:none --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra
|
| 218 | + - name: Log in to Azure |
| 219 | + uses: azure/login@v2 |
| 220 | + if: env.DO_WIN_CODESIGN == 'true' |
| 221 | + with: |
| 222 | + client-id: ${{ secrets.AZURE_CLIENT_ID }} |
| 223 | + tenant-id: ${{ secrets.AZURE_TENANT_ID }} |
| 224 | + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 225 | + - name: Check out repository (for akv-secret Action) |
| 226 | + if: env.DO_WIN_CODESIGN == 'true' |
| 227 | + uses: actions/checkout@v4 |
| 228 | + with: |
| 229 | + path: git |
| 230 | + - name: Download code signing secrets |
| 231 | + id: codesign-secrets |
| 232 | + if: env.DO_WIN_CODESIGN == 'true' |
| 233 | + uses: ./git/.github/actions/akv-secret |
| 234 | + with: |
| 235 | + vault: ${{ secrets.AZURE_VAULT }} |
| 236 | + secrets: | |
| 237 | + ${{ secrets.WIN_CODESIGN_CERT_SECRET_NAME }} base64> home/.sig/codesign.p12 |
| 238 | + ${{ secrets.WIN_CODESIGN_PASS_SECRET_NAME }} > home/.sig/codesign.pass |
195 | 239 | - name: Prepare home directory for code-signing
|
196 |
| - env: |
197 |
| - CODESIGN_P12: ${{secrets.CODESIGN_P12}} |
198 |
| - CODESIGN_PASS: ${{secrets.CODESIGN_PASS}} |
199 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
| 240 | + if: ${{ steps.codesign-secrets.outcome == 'success' }} |
200 | 241 | shell: bash
|
201 | 242 | run: |
|
202 |
| - mkdir -p home/.sig && |
203 |
| - echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 && |
204 |
| - echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass && |
205 | 243 | git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
|
206 | 244 | - name: Retarget auto-update to microsoft/git
|
207 | 245 | shell: bash
|
@@ -234,11 +272,16 @@ jobs:
|
234 | 272 |
|
235 | 273 | b=/usr/src/build-extra &&
|
236 | 274 |
|
237 |
| - sed -i -e '/^ *InstallAutoUpdater();$/a\ |
238 |
| - CustomPostInstall();' \ |
239 |
| - -e '/^ *UninstallAutoUpdater();$/a\ |
240 |
| - CustomPostUninstall();' \ |
241 |
| - $b/installer/install.iss && |
| 275 | + sed -i "# First, find the autoupdater parts in the install/uninstall steps |
| 276 | + /if IsComponentInstalled('autoupdate')/{ |
| 277 | + # slurp in the next two lines, where the call to InstallAutoUpdater()/UninstallAutoUpdater() happens |
| 278 | + N |
| 279 | + N |
| 280 | + # insert the corresponding CustomPostInstall()/CustomPostUninstall() call before that block |
| 281 | + s/^\\([ \t]*\\)\(.*\\)\\(Install\\|Uninstall\\)\\(AutoUpdater\\)/\\1CustomPost\\3();\\n\\1\\2\\3\\4/ |
| 282 | + }" $b/installer/install.iss && |
| 283 | + grep CustomPostInstall $b/installer/install.iss && |
| 284 | + grep CustomPostUninstall $b/installer/install.iss && |
242 | 285 |
|
243 | 286 | cat >>$b/installer/helpers.inc.iss <<\EOF
|
244 | 287 |
|
@@ -301,11 +344,22 @@ jobs:
|
301 | 344 | fi &&
|
302 | 345 | openssl dgst -sha256 artifacts/${{matrix.type.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
|
303 | 346 | - name: Verify that .exe files are code-signed
|
304 |
| - if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != '' |
305 |
| - shell: bash |
| 347 | + if: env.DO_WIN_CODESIGN == 'true' |
| 348 | + shell: pwsh |
306 | 349 | run: |
|
307 |
| - PATH=$PATH:"/c/Program Files (x86)/Windows Kits/10/App Certification Kit/" \ |
308 |
| - signtool verify //pa artifacts/${{matrix.type.fileprefix}}-*.exe |
| 350 | + $ret = 0 |
| 351 | + $files = Get-ChildItem -Path artifacts -Filter "${{matrix.type.fileprefix}}-*.exe" |
| 352 | + foreach ($file in $files) { |
| 353 | + $signature = Get-AuthenticodeSignature -FilePath $file.FullName |
| 354 | + if ($signature.Status -eq 'Valid') { |
| 355 | + Write-Host "[ VALID ] $($file.FullName)" |
| 356 | + } else { |
| 357 | + Write-Host "[INVALID] $($file.FullName)" |
| 358 | + Write-Host " Message: $($signature.StatusMessage)" |
| 359 | + $ret = 1 |
| 360 | + } |
| 361 | + } |
| 362 | + exit $ret |
309 | 363 | - name: Publish ${{matrix.type.name}}-${{matrix.arch.name}}
|
310 | 364 | uses: actions/upload-artifact@v4
|
311 | 365 | with:
|
|
0 commit comments