Skip to content

Commit 2bf73dd

Browse files
committed
feat: add release binaries workflow for cross-platform builds
1 parent 2574558 commit 2bf73dd

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Release Binaries
2+
3+
on:
4+
push:
5+
tags: [ "v*" ] # e.g. v0.1.0
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write # required for gh release
10+
11+
jobs:
12+
#-----------------------------------------------------------
13+
# 1. Build matrix - each row runs on its own VM
14+
#-----------------------------------------------------------
15+
build:
16+
name: Build ${{ matrix.target }}
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
include:
22+
- target: macos-arm64
23+
dagger_fn: macos-build
24+
artifact: pai-sho-${{ github.ref_name }}-macos-arm64.tar.gz
25+
26+
- target: linux-arm64
27+
dagger_fn: linux-arm-64-build
28+
artifact: pai-sho-${{ github.ref_name }}-linux-arm64.tar.gz
29+
30+
- target: linux-amd64
31+
dagger_fn: linux-amd-64-build
32+
artifact: pai-sho-${{ github.ref_name }}-linux-amd64.tar.gz
33+
34+
steps:
35+
# 1) Check out source
36+
- uses: actions/checkout@v4
37+
38+
# 2) Cache Dagger BuildKit cache (restore and save)
39+
- name: Cache Dagger
40+
uses: actions/cache@v4
41+
with:
42+
path: ~/.cache/dagger
43+
key: dagger-${{ runner.os }}-${{ matrix.target }}-${{ github.sha }}
44+
restore-keys: |
45+
dagger-${{ runner.os }}-${{ matrix.target }}-
46+
47+
# 3) Boot the Dagger engine
48+
- name: Setup Dagger
49+
uses: dagger/dagger-for-github@8.0.0
50+
with:
51+
version: "0.18.14"
52+
53+
# 4) Defensive: pre-pull the engine image
54+
- name: Pre-pull Dagger Engine
55+
run: docker pull registry.dagger.io/engine:v0.18.14
56+
57+
# 5) Run one Dagger build function and export artifact
58+
- name: Build with Dagger
59+
uses: dagger/dagger-for-github@8.0.0
60+
with:
61+
version: "0.18.14"
62+
call: ${{ matrix.dagger_fn }} --src upload --src . --version ${{ github.ref_name }} export --path ./artifacts/${{ matrix.artifact }}
63+
64+
# 6) Upload artifact for fan-in job
65+
- name: Upload artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: ${{ matrix.artifact }}
69+
path: ./artifacts/${{ matrix.artifact }}
70+
71+
#-----------------------------------------------------------
72+
# 2. Fan-in job - gather artifacts and create release
73+
#-----------------------------------------------------------
74+
release:
75+
name: Create Release
76+
if: startsWith(github.ref, 'refs/tags/')
77+
runs-on: ubuntu-latest
78+
needs: build
79+
80+
steps:
81+
- uses: actions/checkout@v4
82+
83+
- name: Download artifacts
84+
uses: actions/download-artifact@v4
85+
with:
86+
path: artifacts
87+
merge-multiple: true
88+
89+
- name: Generate changelog if missing
90+
run: |
91+
tag="${{ github.ref_name }}"
92+
changelog="changes/${tag}.md"
93+
if [ ! -f "$changelog" ]; then
94+
# Get the previous tag by sorting all tags and finding the one before current
95+
previous_tag=$(git tag --list 'v*' --sort=-version:refname | grep -A1 "^${tag}$" | tail -1)
96+
if [ -n "$previous_tag" ] && [ "$previous_tag" != "$tag" ]; then
97+
git log --format=%s "${previous_tag}..${tag}" > "$changelog"
98+
else
99+
git log --format=%s "${tag}" > "$changelog"
100+
fi
101+
fi
102+
103+
- name: Publish release
104+
uses: softprops/action-gh-release@v2
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
tag_name: ${{ github.ref_name }}
109+
name: Release ${{ github.ref_name }}
110+
prerelease: ${{ contains(github.ref_name, '-dev.') }}
111+
draft: false
112+
body_path: changes/${{ github.ref_name }}.md
113+
files: artifacts/*

0 commit comments

Comments
 (0)