Skip to content

Commit 6bfd02e

Browse files
committed
ci: add cross-compile workflow for release binaries
1 parent 9c58d29 commit 6bfd02e

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release NoteNest Binaries
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
target:
18+
- aarch64-unknown-linux-musl
19+
- x86_64-unknown-linux-musl
20+
21+
env:
22+
BINARY_NAME: notenest
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Install Rust
29+
uses: dtolnay/rust-toolchain@stable
30+
31+
- name: Cache cargo
32+
uses: Swatinem/rust-cache@v2
33+
34+
- name: Install Cross
35+
run: cargo install cross --locked
36+
37+
- name: Build with Cross
38+
run: cross build --target ${{ matrix.target }} --release --verbose
39+
40+
- name: Create Release Archive
41+
run: |
42+
mkdir -p dist
43+
cp target/${{ matrix.target }}/release/$BINARY_NAME dist/$BINARY_NAME
44+
tar -czvf dist/${{ matrix.target }}.tar.gz -C dist $BINARY_NAME
45+
rm dist/$BINARY_NAME
46+
47+
- name: Upload workflow artifact
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: notenest-${{ matrix.target }}
51+
path: dist/${{ matrix.target }}.tar.gz
52+
53+
- name: Upload release assets
54+
if: startsWith(github.ref, 'refs/tags/')
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
files: dist/${{ matrix.target }}.tar.gz
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)