Skip to content

Commit 32770eb

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 d98be00 commit 32770eb

File tree

1 file changed

+286
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)