Skip to content

Commit b811eb5

Browse files
committed
git-artifacts: allow restricting which artifacts are built
Users can now specify which artifacts they want to build, via the `build_only` input, which is a space-separated list of artifacts. For example, `installer portable` will build `installer-x86_64`, `installer-i686`, `portable-x86_64` and `portable-i686`, and an empty or unset value will build all artifacts. Please note that the `mingw-w64-git` packages are built always, as it would be tricky to figure out when they need to be built (for example, `build_only=portable-x86_64` technically does not need `pkg-i686` to be built, while `build_only=portable` does). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f986fd4 commit b811eb5

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

.github/workflows/git-artifacts.yml

+38-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@ name: git-artifacts
33
on:
44
# This workflow can be triggered manually in the Actions tab, see
55
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
6-
- workflow_dispatch
6+
workflow_dispatch:
7+
inputs:
8+
build_only:
9+
description: 'Optionally restrict what artifacts to build'
710

811
env:
912
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
1013
HOME: "${{github.workspace}}\\home"
1114
MSYSTEM: MINGW64
1215
USERPROFILE: "${{github.workspace}}\\home"
16+
BUILD_ONLY: "${{github.event.inputs.build_only}}"
1317

1418
jobs:
1519
bundle-artifacts:
@@ -232,18 +236,28 @@ jobs:
232236
env:
233237
MSYSTEM: MINGW${{matrix.arch.bitness}}
234238
steps:
239+
- name: Determine whether this job should be skipped
240+
shell: bash
241+
run: |
242+
case " $BUILD_ONLY " in
243+
' ') ;; # not set; build all
244+
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-${{matrix.arch.name}} "*) ;; # build this artifact
245+
*) echo "SKIP=true" >>$GITHUB_ENV;;
246+
esac
235247
- name: Download pkg-${{matrix.arch.name}}
248+
if: env.SKIP != 'true'
236249
uses: actions/download-artifact@v1
237250
with:
238251
name: pkg-${{matrix.arch.name}}
239252
path: pkg-${{matrix.arch.name}}
240253
- name: Download bundle-artifacts
254+
if: env.SKIP != 'true'
241255
uses: actions/download-artifact@v1
242256
with:
243257
name: bundle-artifacts
244258
path: bundle-artifacts
245259
- name: Download git-sdk-64-build-installers
246-
if: matrix.arch.bitness == '64'
260+
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
247261
shell: bash
248262
run: |
249263
# Use Git Bash to download and unpack the artifact
@@ -259,7 +273,7 @@ jobs:
259273
## Unpack artifact
260274
unzip artifacts.zip
261275
- name: Download git-sdk-32-build-installers
262-
if: matrix.arch.bitness == '32'
276+
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
263277
shell: bash
264278
run: |
265279
# Use Git Bash to download and unpack the artifact
@@ -276,6 +290,7 @@ jobs:
276290
## Unpack artifact
277291
unzip artifacts.zip
278292
- name: Clone and update build-extra
293+
if: env.SKIP != 'true'
279294
shell: bash
280295
run: |
281296
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
@@ -285,14 +300,15 @@ jobs:
285300
env:
286301
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
287302
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
288-
if: (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
303+
if: env.SKIP != 'true' && (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
289304
shell: bash
290305
run: |
291306
mkdir -p home/.sig &&
292307
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
293308
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
294309
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
295310
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
311+
if: env.SKIP != 'true'
296312
shell: powershell
297313
run: |
298314
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
@@ -305,7 +321,7 @@ jobs:
305321
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed \"s/.* //\" >artifacts/sha-256.txt
306322
"@
307323
- name: Copy package-versions and pdbs
308-
if: matrix.artifact.name == 'installer'
324+
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
309325
shell: powershell
310326
run: |
311327
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
@@ -319,10 +335,11 @@ jobs:
319335
GIT_CONFIG_PARAMETERS=\"'windows.sdk${{matrix.arch.bitness}}.path='\" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory=\"`$a\" installer/package-versions.txt)
320336
"@
321337
- name: Clean up temporary files
322-
if: always()
338+
if: always() && env.SKIP != 'true'
323339
shell: bash
324340
run: rm -rf home
325341
- name: Publish ${{matrix.artifact.name}}-${{matrix.arch.name}}
342+
if: env.SKIP != 'true'
326343
uses: actions/upload-artifact@v1
327344
with:
328345
name: ${{matrix.artifact.name}}-${{matrix.arch.name}}
@@ -331,17 +348,28 @@ jobs:
331348
runs-on: windows-latest
332349
needs: pkg
333350
steps:
351+
- name: Determine whether this job should be skipped
352+
shell: bash
353+
run: |
354+
case " $BUILD_ONLY " in
355+
' ') ;; # not set; build all
356+
*" nuget "*) ;; # build this artifact
357+
*) echo "SKIP=true" >>$GITHUB_ENV;;
358+
esac
334359
- name: Download pkg-x86_64
360+
if: env.SKIP != 'true'
335361
uses: actions/download-artifact@v1
336362
with:
337363
name: pkg-x86_64
338364
path: pkg-x86_64
339365
- name: Download bundle-artifacts
366+
if: env.SKIP != 'true'
340367
uses: actions/download-artifact@v1
341368
with:
342369
name: bundle-artifacts
343370
path: bundle-artifacts
344371
- name: Download git-sdk-64-build-installers
372+
if: env.SKIP != 'true'
345373
shell: bash
346374
run: |
347375
# Use Git Bash to download and unpack the artifact
@@ -357,13 +385,16 @@ jobs:
357385
## Unpack artifact
358386
unzip artifacts.zip
359387
- name: Clone and update build-extra
388+
if: env.SKIP != 'true'
360389
shell: bash
361390
run: |
362391
d=git-sdk-64-build-installers/usr/src/build-extra &&
363392
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
364393
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
365394
- uses: nuget/setup-nuget@v1
395+
if: env.SKIP != 'true'
366396
- name: Build 64-bit NuGet packages
397+
if: env.SKIP != 'true'
367398
shell: powershell
368399
run: |
369400
& .\git-sdk-64-build-installers\usr\bin\bash.exe -lc @"
@@ -372,6 +403,7 @@ jobs:
372403
openssl dgst -sha256 artifacts/Git*.nupkg | sed \"s/.* //\" >artifacts/sha-256.txt
373404
"@
374405
- name: Publish nuget-x86_64
406+
if: env.SKIP != 'true'
375407
uses: actions/upload-artifact@v1
376408
with:
377409
name: nuget-x86_64

0 commit comments

Comments
 (0)