Skip to content

Commit 7f46aaa

Browse files
committed
Add artifact matrix
1 parent 526689b commit 7f46aaa

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
build_only:
7-
description: 'Optionally restrict what artifacts to build. Separate artifacts with spaces'
7+
description: 'Optionally restrict what artifacts to build (portable, installer, etc.). Separate artifacts with spaces'
88
required: false
99
ref:
1010
description: 'Optionally override which branch to build'
@@ -128,6 +128,8 @@ jobs:
128128
pkg:
129129
runs-on: windows-latest
130130
needs: bundle-artifacts
131+
outputs:
132+
artifact_matrix: ${{steps.artifact-build-matrix.outputs.matrix}}
131133
env:
132134
MSYSTEM: ${{ needs.bundle-artifacts.outputs.msystem }}
133135
MINGW_PREFIX: ${{ needs.bundle-artifacts.outputs.mingw_prefix }}
@@ -227,3 +229,81 @@ jobs:
227229
with:
228230
name: pkg-${{env.ARCHITECTURE}}
229231
path: artifacts
232+
- uses: actions/setup-node@v3
233+
with:
234+
node-version: 16
235+
- name: Prepare artifact build matrix
236+
id: artifact-build-matrix
237+
run: |
238+
ARTIFACTS=$(test -n "$BUILD_ONLY" && echo $BUILD_ONLY || echo "installer portable archive mingit mingit-busybox")
239+
MATRIX=$(node ./create-artifacts-matrix.js $ARTIFACTS)
240+
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
241+
artifacts:
242+
runs-on: windows-latest
243+
needs: [bundle-artifacts, pkg]
244+
env:
245+
MSYSTEM: ${{ needs.bundle-artifacts.outputs.msystem }}
246+
BITNESS: ${{ needs.bundle-artifacts.outputs.bitness }}
247+
strategy:
248+
fail-fast: false
249+
matrix: ${{ fromJSON(needs.pkg.outputs.artifact_matrix) }}
250+
steps:
251+
- name: Download pkg-${{env.ARCHITECTURE}}
252+
uses: actions/download-artifact@v3
253+
with:
254+
name: pkg-${{env.ARCHITECTURE}}
255+
path: pkg-${{env.ARCHITECTURE}}
256+
- name: Download bundle-artifacts
257+
uses: actions/download-artifact@v3
258+
with:
259+
name: bundle-artifacts
260+
path: bundle-artifacts
261+
- uses: git-for-windows/setup-git-for-windows-sdk@v1
262+
with:
263+
flavor: build-installers
264+
architecture: ${{env.ARCHITECTURE}}
265+
- name: Clone and update build-extra
266+
run: |
267+
d=/usr/src/build-extra &&
268+
if test ! -d $d/.git
269+
then
270+
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d
271+
else
272+
git -C $d fetch https://github.com/git-for-windows/build-extra main &&
273+
git -C $d switch -C main FETCH_HEAD
274+
fi &&
275+
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
276+
- name: Prepare home directory for code-signing
277+
env:
278+
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
279+
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
280+
if: (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
281+
run: |
282+
mkdir -p home/.sig &&
283+
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
284+
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
285+
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
286+
- name: Build ${{env.ARCHITECTURE}} ${{matrix.artifact.name}}
287+
run: |
288+
set -x
289+
eval /usr/src/build-extra/please.sh make_installers_from_mingw_w64_git --version=$(cat pkg-${{env.ARCHITECTURE}}/ver) -o artifacts --${{matrix.artifact.name}} --pkg=pkg-${{env.ARCHITECTURE}}/mingw-w64-${{env.ARCHITECTURE}}-git-[0-9]*.tar.xz --pkg=pkg-${{env.ARCHITECTURE}}/mingw-w64-${{env.ARCHITECTURE}}-git-doc-html-[0-9]*.tar.xz &&
290+
if test portable = '${{matrix.artifact.name}}' && test -n "$(git config alias.signtool)"
291+
then
292+
git signtool artifacts/PortableGit-*.exe
293+
fi &&
294+
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed "s/.* //" >artifacts/sha-256.txt
295+
- name: Copy package-versions and pdbs
296+
if: matrix.artifact.name == 'installer'
297+
run: |
298+
cp /usr/src/build-extra/installer/package-versions.txt artifacts/ &&
299+
a=$PWD/artifacts &&
300+
p=$PWD/pkg-${{env.ARCHITECTURE}} &&
301+
(cd /usr/src/build-extra &&
302+
mkdir -p cached-source-packages &&
303+
cp "$p"/*-pdb* cached-source-packages/ &&
304+
GIT_CONFIG_PARAMETERS="'windows.sdk${{env.BITNESS}}.path='" ./please.sh bundle_pdbs --arch=${{env.ARCHITECTURE}} --directory="$a" installer/package-versions.txt)
305+
- name: Publish ${{matrix.artifact.name}}-${{env.ARCHITECTURE}}
306+
uses: actions/upload-artifact@v3
307+
with:
308+
name: ${{matrix.artifact.name}}-${{env.ARCHITECTURE}}
309+
path: artifacts

create-artifacts-matrix.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const artifacts = process.argv.slice(2)
2+
3+
if (artifacts.length < 1) {
4+
throw new Error("No artifacts provided. Provide in the format ./create-artifacts-matrix.js ARTIFACT1 ARTIFACT2")
5+
}
6+
7+
const validArtifacts = [
8+
{
9+
name: "installer",
10+
filePrefix: "Git",
11+
fileExtension: "exe"
12+
},
13+
{
14+
name: "portable",
15+
filePrefix: "PortableGit",
16+
fileExtension: "exe"
17+
},
18+
{
19+
name: "archive",
20+
filePrefix: "Git",
21+
fileExtension: "tar.bz2"
22+
},
23+
{
24+
name: "mingit",
25+
filePrefix: "MinGit",
26+
fileExtension: "zip"
27+
},
28+
{
29+
name: "mingit-busybox",
30+
filePrefix: "MinGit",
31+
fileExtension: "zip"
32+
}
33+
]
34+
35+
const artifactsToBuild = []
36+
37+
for (const artifact of artifacts) {
38+
const artifactObject = validArtifacts.find(a => a.name === artifact)
39+
if (!artifactObject) {
40+
throw new Error(`${artifact} is not a valid artifact`)
41+
}
42+
43+
artifactsToBuild.push(artifactObject)
44+
}
45+
46+
console.log(JSON.stringify({artifact: artifactsToBuild}))

0 commit comments

Comments
 (0)