Skip to content

Commit 1792d5b

Browse files
committed
Add github actions workflow
1 parent 564294a commit 1792d5b

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/workflows/release.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
target: x86_64-unknown-linux-gnu
22+
- os: ubuntu-latest
23+
target: aarch64-unknown-linux-gnu
24+
- os: macos-latest
25+
target: aarch64-apple-darwin
26+
- os: macos-latest
27+
target: x86_64-apple-darwin
28+
- os: windows-latest
29+
target: x86_64-pc-windows-msvc
30+
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
35+
- name: Install Rust
36+
uses: dtolnay/rust-toolchain@stable
37+
with:
38+
targets: ${{ matrix.target }}
39+
40+
- name: Install cross (Linux cross-compiling)
41+
if: matrix.target == 'aarch64-unknown-linux-gnu'
42+
run: cargo install cross --git https://github.com/cross-rs/cross
43+
44+
- name: Build
45+
run: |
46+
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
47+
cross build --release --target ${{ matrix.target }}
48+
else
49+
cargo build --release --target ${{ matrix.target }}
50+
fi
51+
52+
- name: Prepare artifact
53+
run: |
54+
BIN_NAME=hammerload
55+
OUT_DIR=release
56+
mkdir -p $OUT_DIR
57+
58+
if [[ "${{ matrix.target }}" == *"windows"* ]]; then
59+
cp target/${{ matrix.target }}/release/${BIN_NAME}.exe $OUT_DIR/${BIN_NAME}-${{ matrix.target }}.exe
60+
else
61+
cp target/${{ matrix.target }}/release/${BIN_NAME} $OUT_DIR/${BIN_NAME}-${{ matrix.target }}
62+
fi
63+
64+
- name: Upload artifact
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: binaries-${{ matrix.target }}
68+
path: release/
69+
70+
release:
71+
name: Create GitHub Release
72+
needs: build
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Download all build artifacts
77+
uses: actions/download-artifact@v4
78+
with:
79+
pattern: binaries-*
80+
merge-multiple: true
81+
82+
- name: Generate checksums
83+
run: |
84+
shasum -a 256 * > SHA256SUMS.txt
85+
86+
- name: Create Release
87+
uses: softprops/action-gh-release@v2
88+
with:
89+
files: |
90+
hammerload-*
91+
SHA256SUMS.txt

0 commit comments

Comments
 (0)