Skip to content

Commit 1def6ad

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 6a0adca commit 1def6ad

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:
@@ -98,43 +102,62 @@ jobs:
98102
git remote add -f origin https://github.com/git-for-windows/git &&
99103
git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} &&
100104
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
101120
- 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' }}
106122
shell: bash
107123
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
112124
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
113135
- name: Prepare home directory for GPG signing
114-
if: env.GPGKEY != ''
136+
if: ${{ steps.gpg-secrets.outputs.keygrip != '' && steps.gpg-secrets.outputs.private-key != '' }}
115137
shell: bash
116138
run: |
117139
# This section ensures that the identity for the GPG key matches the git user identity, otherwise
118140
# signing will fail
119141
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}')" &&
122146
git config --global user.name "${info% <*}" &&
123147
git config --global user.email "<${info#*<}"
124-
env:
125-
GPGKEY: ${{secrets.GPGKEY}}
126148
- name: Build mingw-w64-${{matrix.arch.toolchain}}-git
127-
env:
128-
GPGKEY: "${{secrets.GPGKEY}}"
129149
shell: bash
130150
run: |
131151
set -x
132152
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+
133156
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
134157
printf '#!/bin/sh\n\nexec /${{matrix.arch.mingwprefix}}/bin/git.exe "$@"\n' >/usr/bin/git &&
135158
136159
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 }}"
138161
then
139162
for tar in artifacts/*.tar*
140163
do
@@ -192,16 +215,31 @@ jobs:
192215
shell: bash
193216
run: |
194217
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
195239
- 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' }}
200241
shell: bash
201242
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 &&
205243
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
206244
- name: Retarget auto-update to microsoft/git
207245
shell: bash
@@ -234,11 +272,16 @@ jobs:
234272
235273
b=/usr/src/build-extra &&
236274
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 &&
242285
243286
cat >>$b/installer/helpers.inc.iss <<\EOF
244287
@@ -301,11 +344,22 @@ jobs:
301344
fi &&
302345
openssl dgst -sha256 artifacts/${{matrix.type.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
303346
- 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
306349
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
309363
- name: Publish ${{matrix.type.name}}-${{matrix.arch.name}}
310364
uses: actions/upload-artifact@v4
311365
with:

0 commit comments

Comments
 (0)