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
85
86
87
88
89
90
91
92
93
94
name: Release
# Tag-driven releases. Bump the version in Cargo.toml, then:
# git tag v0.2.0 && git push <remote> v0.2.0
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
# Create the GitHub Release that the other jobs upload assets to.
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Cross-compiled binaries (tar.gz) for Linux + macOS, attached to the release.
# Archive names match scripts/install.sh: sara-<target>.tar.gz
#
# There is deliberately no `use-cross` input: it is not a valid input for
# upload-rust-binary-action, which warned "Unexpected input(s) 'use-cross'"
# and ignored it on every run. The action already installs and uses `cross`
# by itself when the target needs it — the v1.4.0 aarch64-unknown-linux-gnu
# asset was verified as a genuine `ELF 64-bit ARM aarch64` binary.
binaries:
needs: create-release
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Build and upload
uses: taiki-e/upload-rust-binary-action@v1
with:
bin: sara
target: ${{ matrix.target }}
archive: sara-$target
checksum: sha256
token: ${{ secrets.GITHUB_TOKEN }}
# Debian package (.deb) for amd64. Uploaded both versioned (cargo-deb's name)
# and as a stable `sara_amd64.deb` so the README's latest-download URL works.
deb:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-deb
run: cargo install cargo-deb --locked
- name: Build .deb
run: cargo deb
- name: Upload .deb to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
deb="$(ls target/debian/*.deb | head -n1)"
cp "$deb" sara_amd64.deb
sha256sum "$deb" sara_amd64.deb > sara_amd64.deb.sha256
gh release upload "${GITHUB_REF_NAME}" "$deb" sara_amd64.deb sara_amd64.deb.sha256 --clobber
# Publish to crates.io. No-op unless the CARGO_REGISTRY_TOKEN secret is set.
crates-io:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Publish
env:
TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
if [ -z "${TOKEN:-}" ]; then
echo "CARGO_REGISTRY_TOKEN not set — skipping crates.io publish."
exit 0
fi
cargo publish --token "$TOKEN"