Skip to content

Commit 935db65

Browse files
author
Alejandro Alvarez
committed
🔧 (.github/workflows/attach-artifact-release.yml): update output variable name to match the correct syntax for GitHub Actions
✨ (.github/workflows/attach-artifact-release.yml): add support for attaching multiple artifacts to a release based on different architectures using a matrix strategy
1 parent c30bca0 commit 935db65

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

‎.github/workflows/attach-artifact-release.yml‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ env:
1111
VERSION: ${{ inputs.version }}
1212

1313
jobs:
14-
attach-to-release:
14+
prepare-release:
1515
name: Attach Artifact to Release
1616
runs-on: ubuntu-latest
17+
outputs:
18+
upload_url: ${{ steps.get-release.outputs.upload_url }}
1719
steps:
1820
- uses: actions/checkout@v4
1921

@@ -43,7 +45,8 @@ jobs:
4345
LATEST_DRAFT_RELEASE_URL=$(curl -X GET -H "Authorization: token ${{ secrets.BOT_TOKEN }}" "https://api.github.com/repos/${{ github.repository }}/releases?per_page=1" | jq -r 'if .[].draft == true then .[].upload_url else empty end')
4446
echo "Latest Draft Release ID: $LATEST_DRAFT_RELEASE"
4547
echo "Latest Draft Release upload_url: $LATEST_DRAFT_RELEASE_URL"
46-
echo "RELEASE_UPLOAD_URL=$LATEST_DRAFT_RELEASE_URL" >> $GITHUB_ENV
48+
echo "RELEASE_ID=$LATEST_DRAFT_RELEASE" >> $GITHUB_ENV
49+
echo "upload_url=$LATEST_DRAFT_RELEASE_URL" >> $GITHUB_OUTPUT
4750
4851
- name: List artifacts in release
4952
if: env.RELEASE_ID != '' && env.RELEASE_ID != null
@@ -66,12 +69,26 @@ jobs:
6669
echo "Deleted artifact ID: $value"
6770
done
6871
69-
- name: Attach darwin_amd64 artifact to release
72+
attach-to-release:
73+
runs-on: ubuntu-latest
74+
needs: prepare-release
75+
strategy:
76+
matrix:
77+
arch: [
78+
{folder: darwin_amd64, zip_name: darwin},
79+
{folder: darwin_arm64, zip_name: darwin-arm64},
80+
{folder: linux_amd64, zip_name: linux},
81+
{folder: linux_arm64, zip_name: linux-arm64},
82+
{folder: s390x, zip_name: s390x},
83+
{folder: windows, zip_name: windows},
84+
]
85+
steps:
86+
- name: Attach artifact to release
7087
uses: actions/[email protected]
7188
env:
7289
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7390
with:
74-
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
75-
asset_path: ./bin/darwin_amd64/lpm-${{ env.version }}-darwin.zip
76-
asset_name: lpm-${{ env.version }}-darwin.zip
91+
upload_url: ${{ needs.prepare-release.outputs.upload_url }}
92+
asset_path: bin/${{ matrix.arch.folder }}/lpm-${{ env.VERSION }}-${{ matrix.arch.zip_name }}.zip
93+
asset_name: lpm-${{ env.VERSION }}-${{ matrix.arch.zip_name }}.zip
7794
asset_content_type: application/zip

0 commit comments

Comments
 (0)