Skip to content

Commit 550da4c

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 7a48866 commit 550da4c

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

.github/workflows/git-artifacts.yml

Lines changed: 38 additions & 6 deletions
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:
@@ -230,18 +234,28 @@ jobs:
230234
env:
231235
MSYSTEM: MINGW${{matrix.arch.bitness}}
232236
steps:
237+
- name: Determine whether this job should be skipped
238+
shell: bash
239+
run: |
240+
case " $BUILD_ONLY " in
241+
' ') ;; # not set; build all
242+
*" ${{matrix.artifact.name}} "*|*" ${{matrix.artifact.name}}-${{matrix.arch.name}} "*) ;; # build this artifact
243+
*) echo "SKIP=true" >>$GITHUB_ENV;;
244+
esac
233245
- name: Download pkg-${{matrix.arch.name}}
246+
if: env.SKIP != 'true'
234247
uses: actions/download-artifact@v1
235248
with:
236249
name: pkg-${{matrix.arch.name}}
237250
path: pkg-${{matrix.arch.name}}
238251
- name: Download bundle-artifacts
252+
if: env.SKIP != 'true'
239253
uses: actions/download-artifact@v1
240254
with:
241255
name: bundle-artifacts
242256
path: bundle-artifacts
243257
- name: Download git-sdk-64-build-installers
244-
if: matrix.arch.bitness == '64'
258+
if: env.SKIP != 'true' && matrix.arch.bitness == '64'
245259
shell: bash
246260
run: |
247261
# Use Git Bash to download and unpack the artifact
@@ -257,7 +271,7 @@ jobs:
257271
## Unpack artifact
258272
unzip artifacts.zip
259273
- name: Download git-sdk-32-build-installers
260-
if: matrix.arch.bitness == '32'
274+
if: env.SKIP != 'true' && matrix.arch.bitness == '32'
261275
shell: bash
262276
run: |
263277
# Use Git Bash to download and unpack the artifact
@@ -274,6 +288,7 @@ jobs:
274288
## Unpack artifact
275289
unzip artifacts.zip
276290
- name: Clone and update build-extra
291+
if: env.SKIP != 'true'
277292
shell: bash
278293
run: |
279294
d=git-sdk-${{matrix.arch.bitness}}-build-installers/usr/src/build-extra &&
@@ -283,14 +298,15 @@ jobs:
283298
env:
284299
CODESIGN_P12: ${{secrets.CODESIGN_P12}}
285300
CODESIGN_PASS: ${{secrets.CODESIGN_PASS}}
286-
if: (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
301+
if: env.SKIP != 'true' && (matrix.artifact.name == 'installer' || matrix.artifact.name == 'portable') && env.CODESIGN_P12 != '' && env.CODESIGN_PASS != ''
287302
shell: bash
288303
run: |
289304
mkdir -p home/.sig &&
290305
echo -n "$CODESIGN_P12" | tr % '\n' | base64 -d >home/.sig/codesign.p12 &&
291306
echo -n "$CODESIGN_PASS" >home/.sig/codesign.pass &&
292307
git config --global alias.signtool '!sh "/usr/src/build-extra/signtool.sh"'
293308
- name: Build ${{matrix.arch.bitness}}-bit ${{matrix.artifact.name}}
309+
if: env.SKIP != 'true'
294310
shell: powershell
295311
run: |
296312
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
@@ -303,7 +319,7 @@ jobs:
303319
openssl dgst -sha256 artifacts/${{matrix.artifact.fileprefix}}-*.${{matrix.artifact.fileextension}} | sed \"s/.* //\" >artifacts/sha-256.txt
304320
"@
305321
- name: Copy package-versions and pdbs
306-
if: matrix.artifact.name == 'installer'
322+
if: env.SKIP != 'true' && matrix.artifact.name == 'installer'
307323
shell: powershell
308324
run: |
309325
& .\git-sdk-${{matrix.arch.bitness}}-build-installers\usr\bin\bash.exe -lc @"
@@ -317,10 +333,11 @@ jobs:
317333
GIT_CONFIG_PARAMETERS=\"'windows.sdk${{matrix.arch.bitness}}.path='\" ./please.sh bundle_pdbs --arch=${{matrix.arch.name}} --directory=\"`$a\" installer/package-versions.txt)
318334
"@
319335
- name: Clean up temporary files
320-
if: always()
336+
if: always() && env.SKIP != 'true'
321337
shell: bash
322338
run: rm -rf home
323339
- name: Publish ${{matrix.artifact.name}}-${{matrix.arch.name}}
340+
if: env.SKIP != 'true'
324341
uses: actions/upload-artifact@v1
325342
with:
326343
name: ${{matrix.artifact.name}}-${{matrix.arch.name}}
@@ -329,17 +346,28 @@ jobs:
329346
runs-on: windows-latest
330347
needs: pkg
331348
steps:
349+
- name: Determine whether this job should be skipped
350+
shell: bash
351+
run: |
352+
case " $BUILD_ONLY " in
353+
' ') ;; # not set; build all
354+
*" nuget "*) ;; # build this artifact
355+
*) echo "SKIP=true" >>$GITHUB_ENV;;
356+
esac
332357
- name: Download pkg-x86_64
358+
if: env.SKIP != 'true'
333359
uses: actions/download-artifact@v1
334360
with:
335361
name: pkg-x86_64
336362
path: pkg-x86_64
337363
- name: Download bundle-artifacts
364+
if: env.SKIP != 'true'
338365
uses: actions/download-artifact@v1
339366
with:
340367
name: bundle-artifacts
341368
path: bundle-artifacts
342369
- name: Download git-sdk-64-build-installers
370+
if: env.SKIP != 'true'
343371
shell: bash
344372
run: |
345373
# Use Git Bash to download and unpack the artifact
@@ -355,13 +383,16 @@ jobs:
355383
## Unpack artifact
356384
unzip artifacts.zip
357385
- name: Clone and update build-extra
386+
if: env.SKIP != 'true'
358387
shell: bash
359388
run: |
360389
d=git-sdk-64-build-installers/usr/src/build-extra &&
361390
git clone --single-branch -b main https://github.com/git-for-windows/build-extra $d &&
362391
git -C $d pull "$PWD"/bundle-artifacts/build-extra.bundle main
363392
- uses: nuget/setup-nuget@v1
393+
if: env.SKIP != 'true'
364394
- name: Build 64-bit NuGet packages
395+
if: env.SKIP != 'true'
365396
shell: powershell
366397
run: |
367398
& .\git-sdk-64-build-installers\usr\bin\bash.exe -lc @"
@@ -370,6 +401,7 @@ jobs:
370401
openssl dgst -sha256 artifacts/Git*.nupkg | sed \"s/.* //\" >artifacts/sha-256.txt
371402
"@
372403
- name: Publish nuget-x86_64
404+
if: env.SKIP != 'true'
373405
uses: actions/upload-artifact@v1
374406
with:
375407
name: nuget-x86_64

0 commit comments

Comments
 (0)