From 3608ae200fa41df5e351dad0098556fecb805353 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 7 Nov 2024 04:13:56 -0800 Subject: [PATCH] Don't upload multiple times to same artifact in build workflow 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. --- .github/workflows/build.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72136c4..4fe7180 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,6 +11,9 @@ on: branches: - main +env: + ARTIFACT_PREFIX: dist- + jobs: build: @@ -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 }} @@ -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 @@ -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]