Skip to content

Commit 2e6952f

Browse files
authored
Merge pull request #368 from gren-lang/auto-upload-build
Automatically upload build artifacts on release
2 parents 7f11540 + 0108fed commit 2e6952f

1 file changed

Lines changed: 41 additions & 3 deletions

File tree

.github/workflows/build.yml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
branches: [main]
66
push:
77
branches: [main]
8+
release:
9+
types: [published]
810

911
env:
1012
ghc: "9.10.3"
@@ -47,7 +49,7 @@ jobs:
4749
artifact: gren_linux
4850
- runner: ubuntu-24.04-arm
4951
arch: aarch64
50-
artifact: gren_linux_arm64
52+
artifact: gren_linux_aarch64
5153

5254
runs-on: ${{ matrix.runner }}
5355

@@ -121,7 +123,11 @@ jobs:
121123
needs: validate-code-formatting
122124
strategy:
123125
matrix:
124-
os: [macos-15, macos-15-intel]
126+
include:
127+
- os: macos-15
128+
artifact: gren_mac_aarch64
129+
- os: macos-15-intel
130+
artifact: gren_mac
125131

126132
runs-on: ${{ matrix.os }}
127133

@@ -175,7 +181,7 @@ jobs:
175181

176182
- uses: actions/upload-artifact@v4
177183
with:
178-
name: gren-${{ matrix.os }}
184+
name: ${{ matrix.artifact }}
179185
path: gren
180186
retention-days: 14
181187

@@ -234,3 +240,35 @@ jobs:
234240
name: gren.exe
235241
path: gren
236242
retention-days: 14
243+
244+
publish-release:
245+
needs: [linux, mac, windows]
246+
if: github.event_name == 'release'
247+
runs-on: ubuntu-latest
248+
permissions:
249+
contents: write
250+
251+
steps:
252+
- name: Download all build artifacts
253+
uses: actions/download-artifact@v4
254+
with:
255+
path: artifacts
256+
257+
- name: Stage release assets
258+
run: |
259+
set -eux
260+
mkdir release-assets
261+
for name in gren_linux gren_linux_aarch64 gren_mac gren_mac_aarch64 gren.exe; do
262+
cp "artifacts/$name/gren" "release-assets/$name"
263+
done
264+
265+
- name: Upload assets to release
266+
env:
267+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
268+
GH_REPO: ${{ github.repository }}
269+
TAG: ${{ github.event.release.tag_name }}
270+
run: |
271+
cd release-assets
272+
gh release upload "$TAG" \
273+
gren_linux gren_linux_aarch64 gren_mac gren_mac_aarch64 gren.exe \
274+
--clobber

0 commit comments

Comments
 (0)