Skip to content

Commit b2685fa

Browse files
committed
ci: add release workflow for tagged builds
1 parent e25120b commit b2685fa

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build (${{ matrix.target }})
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
include:
19+
- os: ubuntu-latest
20+
target: x86_64-unknown-linux-gnu
21+
- os: macos-latest
22+
target: x86_64-apple-darwin
23+
- os: windows-latest
24+
target: x86_64-pc-windows-msvc
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Install Rust
30+
uses: dtolnay/rust-toolchain@stable
31+
with:
32+
targets: ${{ matrix.target }}
33+
34+
- name: Rust cache
35+
uses: Swatinem/rust-cache@v2
36+
37+
- name: Build
38+
run: cargo build --locked --release --target ${{ matrix.target }}
39+
40+
- name: Package artifact
41+
shell: bash
42+
run: |
43+
mkdir -p dist
44+
if [ "${{ runner.os }}" = "Windows" ]; then
45+
cp target/${{ matrix.target }}/release/sx.exe dist/sx-${{ github.ref_name }}-${{ matrix.target }}.exe
46+
else
47+
cp target/${{ matrix.target }}/release/sx dist/sx-${{ github.ref_name }}-${{ matrix.target }}
48+
fi
49+
50+
- name: Upload artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: sx-${{ matrix.target }}
54+
path: dist
55+
56+
publish:
57+
name: Publish release
58+
needs: build
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Download artifacts
62+
uses: actions/download-artifact@v4
63+
with:
64+
path: dist
65+
merge-multiple: true
66+
67+
- name: Publish GitHub release
68+
uses: softprops/action-gh-release@v2
69+
with:
70+
generate_release_notes: true
71+
files: dist/*

0 commit comments

Comments
 (0)