1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Release
on:
push:
tags:
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: sparrow-linux-x86_64
- os: macos-latest
target: aarch64-apple-darwin
artifact: sparrow-macos-arm64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: sparrow-windows-x86_64.exe
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Rename binary (prevent cross-platform name collision)
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [ -f sparrow.exe ]; then
mv sparrow.exe "${{ matrix.artifact }}"
elif [ -f sparrow ]; then
mv sparrow "${{ matrix.artifact }}"
else
echo "sparrow binary not found" >&2
exit 1
fi
- name: Generate checksums
shell: bash
run: |
cd target/${{ matrix.target }}/release
sha256sum "${{ matrix.artifact }}" > "${{ matrix.artifact }}.sha256"
cat "${{ matrix.artifact }}.sha256"
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
target/${{ matrix.target }}/release/${{ matrix.artifact }}
target/${{ matrix.target }}/release/${{ matrix.artifact }}.sha256
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
- name: Clean stale release assets
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
if ! gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
exit 0
fi
gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets[].name' |
while IFS= read -r asset; do
[ -n "$asset" ] && gh release delete-asset "$GITHUB_REF_NAME" "$asset" --repo "$GITHUB_REPOSITORY" -y
done
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
generate_release_notes: true