Skip to content

Commit 7f57dd0

Browse files
vdyedscho
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.
1 parent 5727637 commit 7f57dd0

1 file changed

Lines changed: 296 additions & 0 deletions

File tree

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
name: build-git-installers
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]*vfs*' # matches "v<number><any characters>vfs<any characters>"
7+
8+
jobs:
9+
# Check prerequisites for the workflow
10+
prereqs:
11+
runs-on: ubuntu-latest
12+
environment: release
13+
env:
14+
AZ_SUB: ${{ secrets.AZURE_SUBSCRIPTION }}
15+
AZ_CREDS: ${{ secrets.AZURE_CREDENTIALS }}
16+
outputs:
17+
tag_name: ${{ steps.tag.outputs.name }} # The full name of the tag, e.g. v2.32.0.vfs.0.0
18+
tag_version: ${{ steps.tag.outputs.version }} # The version number (without preceding "v"), e.g. 2.32.0.vfs.0.0
19+
steps:
20+
- name: Validate tag
21+
run: |
22+
echo "$GITHUB_REF" |
23+
grep '^refs/tags/v2\.\(0\|[1-9][0-9]*\)\.\(0\|[1-9][0-9]*\)\.vfs\.0\.\(0\|[1-9][0-9]*\)$' || {
24+
echo "::error::${GITHUB_REF#refs/tags/} is not of the form v2.<X>.<Y>.vfs.0.<W>" >&2
25+
exit 1
26+
}
27+
- name: Determine tag to build
28+
run: |
29+
echo "name=${GITHUB_REF#refs/tags/}" >>$GITHUB_OUTPUT
30+
echo "version=${GITHUB_REF#refs/tags/v}" >>$GITHUB_OUTPUT
31+
id: tag
32+
- name: Clone git
33+
uses: actions/checkout@v3
34+
- name: Validate the tag identified with trigger
35+
run: |
36+
die () {
37+
echo "::error::$*" >&2
38+
exit 1
39+
}
40+
41+
# `actions/checkout` only downloads the peeled tag (i.e. the commit)
42+
git fetch origin +$GITHUB_REF:$GITHUB_REF
43+
44+
# Verify that the tag is annotated
45+
test $(git cat-file -t "$GITHUB_REF") == "tag" || die "Tag ${{ steps.tag.outputs.name }} is not annotated"
46+
47+
# Verify tag follows rules in GIT-VERSION-GEN (i.e., matches the specified "DEF_VER" in
48+
# GIT-VERSION-FILE) and matches tag determined from trigger
49+
make GIT-VERSION-FILE
50+
test "${{ steps.tag.outputs.version }}" == "$(sed -n 's/^GIT_VERSION = //p'< GIT-VERSION-FILE)" || die "GIT-VERSION-FILE tag does not match ${{ steps.tag.outputs.name }}"
51+
# End check prerequisites for the workflow
52+
53+
# Build Windows installers (x86_64 installer & portable)
54+
windows_pkg:
55+
runs-on: windows-2019
56+
environment: release
57+
needs: prereqs
58+
env:
59+
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
60+
HOME: "${{github.workspace}}\\home"
61+
USERPROFILE: "${{github.workspace}}\\home"
62+
steps:
63+
- name: Configure user
64+
shell: bash
65+
run:
66+
USER_NAME="${{github.actor}}" &&
67+
USER_EMAIL="${{github.actor}}@users.noreply.github.com" &&
68+
mkdir -p "$HOME" &&
69+
git config --global user.name "$USER_NAME" &&
70+
git config --global user.email "$USER_EMAIL" &&
71+
echo "PACKAGER=$USER_NAME <$USER_EMAIL>" >>$GITHUB_ENV
72+
- uses: git-for-windows/setup-git-for-windows-sdk@v1
73+
with:
74+
flavor: build-installers
75+
- name: Clone build-extra
76+
shell: bash
77+
run: |
78+
git clone --filter=blob:none --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra
79+
- name: Clone git
80+
shell: bash
81+
run: |
82+
# Since we cannot directly clone a specified tag (as we would a branch with `git clone -b <branch name>`),
83+
# this clone has to be done manually (via init->fetch->reset).
84+
85+
tag_name="${{ needs.prereqs.outputs.tag_name }}" &&
86+
git -c init.defaultBranch=main init &&
87+
git remote add -f origin https://github.com/git-for-windows/git &&
88+
git fetch "https://github.com/${{github.repository}}" refs/tags/${tag_name}:refs/tags/${tag_name} &&
89+
git reset --hard ${tag_name}
90+
- name: Prepare home directory for code-signing
91+
env:
92+
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
93+
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
94+
if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
95+
shell: bash
96+
run: |
97+
cd home &&
98+
mkdir -p .sig &&
99+
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >.sig/codesign.p12 &&
100+
echo -n "$CODESIGN_PASS" >.sig/codesign.pass
101+
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
102+
- name: Prepare home directory for GPG signing
103+
if: env.GPGKEY != ''
104+
shell: bash
105+
run: |
106+
# This section ensures that the identity for the GPG key matches the git user identity, otherwise
107+
# signing will fail
108+
109+
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
110+
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
111+
git config --global user.name "${info% <*}" &&
112+
git config --global user.email "<${info#*<}"
113+
env:
114+
GPGKEY: ${{secrets.GPGKEY}}
115+
- name: Build mingw-w64-x86_64-git
116+
env:
117+
GPGKEY: "${{secrets.GPGKEY}}"
118+
shell: bash
119+
run: |
120+
set -x
121+
122+
# Make sure that there is a `/usr/bin/git` that can be used by `makepkg-mingw`
123+
printf '#!/bin/sh\n\nexec /mingw64/bin/git.exe "$@"\n' >/usr/bin/git &&
124+
125+
# Restrict `PATH` to MSYS2 and to Visual Studio (to let `cv2pdb` find the relevant DLLs)
126+
PATH="/mingw64/bin:/usr/bin:/C/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/amd64:/C/Windows/system32"
127+
128+
type -p mspdb140.dll || exit 1
129+
130+
sh -x /usr/src/build-extra/please.sh build-mingw-w64-git --only-64-bit --build-src-pkg -o artifacts HEAD &&
131+
if test -n "$GPGKEY"
132+
then
133+
for tar in artifacts/*.tar*
134+
do
135+
/usr/src/build-extra/gnupg-with-gpgkey.sh --detach-sign --no-armor $tar
136+
done
137+
fi &&
138+
139+
b=$PWD/artifacts &&
140+
version=${{ needs.prereqs.outputs.tag_name }} &&
141+
(cd /usr/src/MINGW-packages/mingw-w64-git &&
142+
cp PKGBUILD.$version PKGBUILD &&
143+
git commit -s -m "mingw-w64-git: new version ($version)" PKGBUILD &&
144+
git bundle create "$b"/MINGW-packages.bundle origin/main..main)
145+
- name: Publish mingw-w64-x86_64-git
146+
uses: actions/upload-artifact@v3
147+
with:
148+
name: pkg-x86_64
149+
path: artifacts
150+
windows_artifacts:
151+
runs-on: windows-2019
152+
environment: release
153+
needs: [prereqs, windows_pkg]
154+
env:
155+
HOME: "${{github.workspace}}\\home"
156+
strategy:
157+
matrix:
158+
artifact:
159+
- name: installer
160+
fileprefix: Git
161+
- name: portable
162+
fileprefix: PortableGit
163+
fail-fast: false
164+
steps:
165+
- name: Download pkg-x86_64
166+
uses: actions/download-artifact@v3
167+
with:
168+
name: pkg-x86_64
169+
path: pkg-x86_64
170+
- uses: git-for-windows/setup-git-for-windows-sdk@v1
171+
with:
172+
flavor: build-installers
173+
- name: Clone build-extra
174+
shell: bash
175+
run: |
176+
git clone --filter=blob:none --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra
177+
- name: Prepare home directory for code-signing
178+
env:
179+
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
180+
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
181+
if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
182+
shell: bash
183+
run: |
184+
mkdir -p home/.sig &&
185+
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
186+
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
187+
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
188+
- name: Retarget auto-update to microsoft/git
189+
shell: bash
190+
run: |
191+
set -x
192+
193+
b=/usr/src/build-extra &&
194+
195+
filename=$b/git-update-git-for-windows.config
196+
tr % '\t' >$filename <<-\EOF &&
197+
[update]
198+
%fromFork = microsoft/git
199+
EOF
200+
201+
sed -i -e '/^#include "file-list.iss"/a\
202+
Source: {#SourcePath}\\..\\git-update-git-for-windows.config; DestDir: {app}\\mingw64\\bin; Flags: replacesameversion; AfterInstall: DeleteFromVirtualStore' \
203+
-e '/^Type: dirifempty; Name: {app}\\{#MINGW_BITNESS}$/i\
204+
Type: files; Name: {app}\\{#MINGW_BITNESS}\\bin\\git-update-git-for-windows.config\
205+
Type: dirifempty; Name: {app}\\{#MINGW_BITNESS}\\bin' \
206+
$b/installer/install.iss
207+
- name: Set the installer Publisher to the Git Fundamentals team
208+
shell: bash
209+
run: |
210+
b=/usr/src/build-extra &&
211+
sed -i -e 's/^\(AppPublisher=\).*/\1The Git Fundamentals Team at GitHub/' $b/installer/install.iss
212+
- name: Let the installer configure Visual Studio to use the installed Git
213+
shell: bash
214+
run: |
215+
set -x
216+
217+
b=/usr/src/build-extra &&
218+
219+
sed -i -e '/^ *InstallAutoUpdater();$/a\
220+
CustomPostInstall();' \
221+
-e '/^ *UninstallAutoUpdater();$/a\
222+
CustomPostUninstall();' \
223+
$b/installer/install.iss &&
224+
225+
cat >>$b/installer/helpers.inc.iss <<\EOF
226+
227+
procedure CustomPostInstall();
228+
begin
229+
if not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\15.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) or
230+
not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\16.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) or
231+
not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\17.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) or
232+
not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\18.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) or
233+
not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\19.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) or
234+
not RegWriteStringValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\20.0\TeamFoundation\GitSourceControl','GitPath',ExpandConstant('{app}')) then
235+
LogError('Could not register TeamFoundation\GitSourceControl');
236+
end;
237+
238+
procedure CustomPostUninstall();
239+
begin
240+
if not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\15.0\TeamFoundation\GitSourceControl','GitPath') or
241+
not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\16.0\TeamFoundation\GitSourceControl','GitPath') or
242+
not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\17.0\TeamFoundation\GitSourceControl','GitPath') or
243+
not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\18.0\TeamFoundation\GitSourceControl','GitPath') or
244+
not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\19.0\TeamFoundation\GitSourceControl','GitPath') or
245+
not RegDeleteValue(HKEY_CURRENT_USER,'Software\Microsoft\VSCommon\20.0\TeamFoundation\GitSourceControl','GitPath') then
246+
LogError('Could not register TeamFoundation\GitSourceControl');
247+
end;
248+
EOF
249+
- name: Enable Scalar/C and the auto-updater in the installer by default
250+
shell: bash
251+
run: |
252+
set -x
253+
254+
b=/usr/src/build-extra &&
255+
256+
sed -i -e "/ChosenOptions:=''/a\\
257+
if (ExpandConstant('{param:components|/}')='/') then begin\n\
258+
WizardSelectComponents('autoupdate');\n\
259+
#ifdef WITH_SCALAR\n\
260+
WizardSelectComponents('scalar');\n\
261+
#endif\n\
262+
end;" $b/installer/install.iss
263+
- name: Build 64-bit ${{matrix.artifact.name}}
264+
shell: bash
265+
run: |
266+
set -x
267+
268+
# Copy the PDB archive to the directory where `--include-pdbs` expects it
269+
b=/usr/src/build-extra &&
270+
mkdir -p $b/cached-source-packages &&
271+
cp pkg-x86_64/*-pdb* $b/cached-source-packages/ &&
272+
273+
# Build the installer, embedding PDBs
274+
eval $b/please.sh make_installers_from_mingw_w64_git --include-pdbs \
275+
--version=${{ needs.prereqs.outputs.tag_version }} \
276+
-o artifacts --${{matrix.artifact.name}} \
277+
--pkg=pkg-x86_64/mingw-w64-x86_64-git-[0-9]*.tar.xz \
278+
--pkg=pkg-x86_64/mingw-w64-x86_64-git-doc-html-[0-9]*.tar.xz &&
279+
280+
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
281+
then
282+
git signtool artifacts/PortableGit-*.exe
283+
fi &&
284+
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.exe | sed "s/.* //" >artifacts/sha-256.txt
285+
- name: Verify that .exe files are code-signed
286+
if: env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
287+
shell: bash
288+
run: |
289+
PATH=$PATH:"/c/Program Files (x86)/Windows Kits/10/App Certification Kit/" \
290+
signtool verify //pa artifacts/${{matrix.artifact.fileprefix}}-*.exe
291+
- name: Publish ${{matrix.artifact.name}}-x86_64
292+
uses: actions/upload-artifact@v3
293+
with:
294+
name: win-${{matrix.artifact.name}}-x86_64
295+
path: artifacts
296+
# End build Windows installers

0 commit comments

Comments
 (0)