Skip to content

Commit a279eac

Browse files
committed
Add release workflow #1
1 parent a645fd3 commit a279eac

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
6+
name: Release Linux binary
7+
8+
jobs:
9+
build-and-release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Install Rust toolchain
16+
uses: actions-rs/toolchain@v1
17+
with:
18+
toolchain: stable
19+
profile: minimal
20+
override: true
21+
22+
- name: Cache Cargo
23+
uses: actions/cache@v4
24+
with:
25+
path: |
26+
~/.cargo/registry
27+
~/.cargo/git
28+
target
29+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-cargo-
32+
33+
- name: Install jq
34+
run: sudo apt-get update && sudo apt-get install -y jq
35+
36+
- name: Determine binary name
37+
id: bin
38+
run: |
39+
BIN_NAME=$(cargo metadata --no-deps --format-version 1 \
40+
| jq -r '.packages[0].targets[] | select(.kind[] | index("bin")) | .name' \
41+
| head -n1)
42+
echo "bin_name=$BIN_NAME" >> $GITHUB_OUTPUT
43+
44+
- name: Build release (x86_64-unknown-linux-gnu)
45+
run: |
46+
rustup target add x86_64-unknown-linux-gnu
47+
cargo build --release --target x86_64-unknown-linux-gnu
48+
49+
- name: Package artifact
50+
run: |
51+
mkdir -p dist
52+
cp target/x86_64-unknown-linux-gnu/release/${{ steps.bin.outputs.bin_name }} dist/
53+
tar -C dist -czf dist/${{ steps.bin.outputs.bin_name }}-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz ${{ steps.bin.outputs.bin_name }}
54+
55+
- name: Create release and upload artifact
56+
uses: ncipollo/release-action@v1
57+
with:
58+
tag: ${{ github.ref_name }}
59+
files: dist/*.tar.gz

0 commit comments

Comments
 (0)