From 341cf7084129203970a22dabd038dada10760d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sun, 29 Dec 2024 10:48:15 -0800 Subject: [PATCH] Attach statically build binary to release Since forever we have wanted to attach statically linked binaries of the program to the corresponding release. However, because GitHub Actions can't seem to get their Matrix workflows interacting with anything, really, that seemed impossible to do. This change proposes a workaround that makes each job of the matrix attach the binary to the release itself, provided that the associated input argument it set. --- .github/workflows/build.yml | 14 ++++++++++++++ .github/workflows/publish.yml | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 552dfa4..c0ceb6b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,13 @@ name: Build on: + workflow_call: + inputs: + upload-release: + description: 'The release to upload artifacts to, if any' + default: '' + required: false + type: string workflow_dispatch: jobs: @@ -24,3 +31,10 @@ jobs: with: name: apcacli path: bin/apcacli + - if: ${{ inputs.upload-release != '' }} + name: Upload release asset + env: + GH_TOKEN: ${{ github.token }} + run: | + mv bin/apcacli apcacli + gh release upload ${{ inputs.upload-release }} apcacli diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4cc9c88..6b8ca5a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,3 +64,9 @@ jobs: run: cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}" env: CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + build-artifacts: + needs: [publish, version] + uses: ./.github/workflows/build.yml + secrets: inherit + with: + upload-release: v${{ needs.version.outputs.version }}