Skip to content

Commit 62cc18c

Browse files
Refactor release workflow with build and artifact upload
Refactor GitHub Actions workflow for release process, adding build and release jobs, and improving artifact handling.
1 parent dfb39f0 commit 62cc18c

File tree

1 file changed

+44
-22
lines changed

1 file changed

+44
-22
lines changed

.github/workflows/release.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,73 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'v*' # Triggers on tags like v1.0, v2.1.3, etc.
6+
- 'v*'
77

88
jobs:
9-
build-and-release:
10-
permissions:
11-
contents: write
12-
9+
build:
1310
runs-on: ${{ matrix.os }}
1411
strategy:
1512
matrix:
1613
os: [ubuntu-latest, macos-latest, windows-latest]
14+
permissions:
15+
contents: read # only need to check out code
1716

1817
steps:
1918
- uses: actions/checkout@v4
2019

2120
- name: Install dependencies (Linux)
2221
if: runner.os == 'Linux'
23-
run: |
24-
sudo apt-get update
25-
sudo apt-get install -y build-essential
22+
run: sudo apt-get update && sudo apt-get install -y build-essential
2623

27-
- name: Build with Make
24+
- name: Build
2825
working-directory: ./mas
2926
shell: bash
3027
run: make
3128

32-
# Determine the correct binary name per OS
33-
- name: Set binary name
34-
id: binary
35-
shell: bash
29+
- name: Upload build artifact
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: binary-${{ runner.os }}
33+
path: |
34+
mas/mas
35+
mas/mas.exe
36+
if-no-files-found: ignore
37+
38+
release:
39+
needs: build
40+
runs-on: ubuntu-latest
41+
permissions:
42+
contents: write # required to publish release
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Download all binaries
47+
uses: actions/download-artifact@v4
48+
with:
49+
path: artifacts
50+
51+
- name: Flatten and rename binaries
3652
run: |
37-
if [[ "${{ runner.os }}" == "Windows" ]]; then
38-
echo "name=mas.exe" >> $GITHUB_OUTPUT
39-
echo "path=mas/mas.exe" >> $GITHUB_OUTPUT
40-
else
41-
echo "name=mas" >> $GITHUB_OUTPUT
42-
echo "path=mas/mas" >> $GITHUB_OUTPUT
53+
mkdir -p release-assets
54+
# Linux
55+
if [ -f "artifacts/binary-Ubuntu/mas/mas" ]; then
56+
cp "artifacts/binary-Ubuntu/mas/mas" release-assets/mas-linux
57+
fi
58+
# macOS
59+
if [ -f "artifacts/binary-macOS/mas/mas" ]; then
60+
cp "artifacts/binary-macOS/mas/mas" release-assets/mas-macos
61+
fi
62+
# Windows
63+
if [ -f "artifacts/binary-Windows/mas/mas.exe" ]; then
64+
cp "artifacts/binary-Windows/mas/mas.exe" release-assets/mas-windows.exe
4365
fi
4466
45-
# Upload binary to the release
46-
- name: Upload release asset
67+
- name: Publish to GitHub Release
4768
uses: softprops/action-gh-release@v2
4869
with:
49-
files: ${{ steps.binary.outputs.path }}
70+
files: release-assets/*
5071
tag_name: ${{ github.ref_name }}
72+
name: Release ${{ github.ref_name }}
5173
draft: false
5274
prerelease: false
5375
env:

0 commit comments

Comments
 (0)