Skip to content

Commit

Permalink
Don't upload multiple times to same artifact in build workflow
Browse files Browse the repository at this point in the history
The "build" workflow produces binaries for a range of target hosts. This is done by using a job matrix in the GitHub
Actions workflow that produces each build in a parallel job. GitHub Actions workflow artifacts are used to transfer the
generated files between sequential jobs in the workflow. The "actions/upload-artifact" action is used for this purpose.

Previously, a single artifact was used for this purpose, with each of the parallel jobs uploading its own generated
files to that artifact. However, support for uploading multiple times to a single artifact was dropped in version 4.0.0
of the "actions/upload-artifact" action. So it is now necessary to use a dedicated artifact for each of the builds.
These can be downloaded in aggregate by using the artifact name globbing and merging features which were introduced in
version 4.1.0 of the "actions/download-artifact" action.
  • Loading branch information
per1234 committed Nov 7, 2024
1 parent 83a018a commit 3608ae2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
branches:
- main

env:
ARTIFACT_PREFIX: dist-

jobs:

build:
Expand All @@ -20,13 +23,16 @@ jobs:
strategy:
matrix:
config:
- os: ubuntu-latest
- artifact-suffix: Linux_64bit
os: ubuntu-latest
ExecutableSuffix: ''
Exports: ''
- os: macos-latest
- artifact-suffix: macOS_ARM64
os: macos-latest
ExecutableSuffix: ''
Exports: 'CGO_ENABLED=1 MACOSX_DEPLOYMENT_TARGET=10.14 '
- os: windows-2019
- artifact-suffix: Windows_64bit
os: windows-2019
ExecutableSuffix: '.exe'
Exports: ''
runs-on: ${{ matrix.config.os }}
Expand All @@ -50,7 +56,7 @@ jobs:
- name: Upload Workflow Artifact [GitHub Actions]
uses: actions/upload-artifact@v4
with:
name: build-artifacts
name: ${{ env.ARTIFACT_PREFIX }}${{ matrix.config.artifact-suffix }}
# this makes the artifact a .zip of the .zip archive, which is currently necessary to preserve the executable file permissions
# see: https://github.com/actions/upload-artifact/issues/38
path: ${{ env.BUILD_OUTPUT_DIRECTORY }}/archive/${{ env.EXECUTABLE_NAME }}_${{ runner.OS }}_amd64.zip
Expand All @@ -63,7 +69,8 @@ jobs:
- name: Download Workflow Artifact [GitHub Actions]
uses: actions/download-artifact@v4
with:
name: build-artifacts
pattern: ${{ env.ARTIFACT_PREFIX }}*
merge-multiple: true
path: build-artifacts

- name: Publish Nightly [S3]
Expand Down

0 comments on commit 3608ae2

Please sign in to comment.