Skip to content

Commit ebab49f

Browse files
hwbehrensampagent
andcommitted
ci: add release workflow to build and upload binaries
Amp-Thread-ID: https://ampcode.com/threads/T-019c606d-2f3d-7776-9fd6-f60dd1022905 Co-authored-by: Amp <amp@ampcode.com>
1 parent 2e4c96b commit ebab49f

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
build:
15+
name: build (${{ matrix.target }})
16+
runs-on: ${{ matrix.os }}
17+
timeout-minutes: 30
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- target: x86_64-unknown-linux-gnu
23+
os: ubuntu-latest
24+
- target: aarch64-unknown-linux-gnu
25+
os: ubuntu-latest
26+
- target: x86_64-apple-darwin
27+
os: macos-latest
28+
- target: aarch64-apple-darwin
29+
os: macos-latest
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: dtolnay/rust-toolchain@stable
35+
with:
36+
targets: ${{ matrix.target }}
37+
38+
- name: Install cross-compilation tools
39+
if: matrix.target == 'aarch64-unknown-linux-gnu'
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y gcc-aarch64-linux-gnu
43+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> "$GITHUB_ENV"
44+
45+
- uses: Swatinem/rust-cache@v2
46+
with:
47+
workspaces: axon
48+
key: ${{ matrix.target }}
49+
50+
- name: Build
51+
working-directory: axon
52+
run: cargo build --release --target ${{ matrix.target }}
53+
54+
- name: Package
55+
run: |
56+
BIN=axon/target/${{ matrix.target }}/release/axon
57+
ARCHIVE=axon-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
58+
tar czf "$ARCHIVE" -C "$(dirname "$BIN")" "$(basename "$BIN")"
59+
echo "ARCHIVE=$ARCHIVE" >> "$GITHUB_ENV"
60+
61+
- name: Upload to release
62+
env:
63+
GH_TOKEN: ${{ github.token }}
64+
run: gh release upload "${{ github.ref_name }}" "${{ env.ARCHIVE }}"

0 commit comments

Comments
 (0)