Skip to content

Commit 7dc327c

Browse files
mjcheethamdscho
authored andcommitted
release: create initial Windows installer build workflow
- trigger on tag matching basic "vfs" version pattern - validate tag is annotated & matches stricter checks - include `scalar` - build x86_64 & portable git installers, upload artifacts to workflow Update Apr 18, 2022: these steps are built explicitly on 'windows-2019' agents (rather than 'windows-latest') to ensure the correct version of Visual Studio is used (verified in the pipeline via 'type -p mspdb140.dll'). Additionally, due to a known (but not-yet-fixed) issue downloading the 'build-installers' flavor of the Git for Windows SDK with the 'git-for-windows/setup-git-for-windows-sdk' Action, the SDK used is the 'full' flavor. Signed-off-by: Victoria Dye <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent bcfec90 commit 7dc327c

File tree

1 file changed

+86
-32
lines changed

1 file changed

+86
-32
lines changed

.github/workflows/build-git-installers.yml

Lines changed: 86 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- 'v[0-9]*vfs*' # matches "v<number><any characters>vfs<any characters>"
77

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+
812
jobs:
913
# Check prerequisites for the workflow
1014
prereqs:
@@ -101,43 +105,62 @@ jobs:
101105
git remote add -f origin https://github.com/git-for-windows/git &&
102106
git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} &&
103107
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
104123
- 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' }}
109125
shell: bash
110126
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
115127
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
116138
- name: Prepare home directory for GPG signing
117-
if: env.GPGKEY != ''
139+
if: ${{ steps.gpg-secrets.outputs.keygrip != '' && steps.gpg-secrets.outputs.private-key != '' }}
118140
shell: bash
119141
run: |
120142
# This section ensures that the identity for the GPG key matches the git user identity, otherwise
121143
# signing will fail
122144
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}')" &&
125149
git config --global user.name "${info% <*}" &&
126150
git config --global user.email "<${info#*<}"
127-
env:
128-
GPGKEY: ${{secrets.GPGKEY}}
129151
- name: Build mingw-w64-${{matrix.arch.toolchain}}-git
130-
env:
131-
GPGKEY: "${{secrets.GPGKEY}}"
132152
shell: bash
133153
run: |
134154
set -x
135155
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+
136159
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
137160
printf '#!/bin/sh\n\nexec /${{matrix.arch.mingwprefix}}/bin/git.exe "$@"\n' >/usr/bin/git &&
138161
139162
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 }}"
141164
then
142165
for tar in artifacts/*.tar*
143166
do
@@ -195,16 +218,31 @@ jobs:
195218
shell: bash
196219
run: |
197220
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
198242
- 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' }}
203244
shell: bash
204245
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 &&
208246
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
209247
- name: Retarget auto-update to microsoft/git
210248
shell: bash
@@ -237,11 +275,16 @@ jobs:
237275
238276
b=/usr/src/build-extra &&
239277
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 &&
245288
246289
cat >>$b/installer/helpers.inc.iss <<\EOF
247290
@@ -304,11 +347,22 @@ jobs:
304347
fi &&
305348
openssl dgst -sha256 artifacts/${{matrix.type.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
306349
- 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
309352
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
312366
- name: Publish ${{matrix.type.name}}-${{matrix.arch.name}}
313367
uses: actions/upload-artifact@v4
314368
with:

0 commit comments

Comments
 (0)