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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/create-gh-release-action@v1
with:
# Release body is taken from the matching section of CHANGELOG.md.
changelog: CHANGELOG.md
token: ${{ secrets.GITHUB_TOKEN }}
upload-assets:
needs: create-release
strategy:
# Build every target even if one fails: a broken aarch64 build must
# not cancel the x86_64 binaries most users need.
fail-fast: false
matrix:
include:
# We build on ubuntu-22.04 (not -latest) on purpose: the resulting
# gnu binaries link against an older glibc, so they run on the aging
# distros commonly found on HPC cluster login nodes.
# The musl target is a fully static binary that works even on
# CentOS7-era login nodes where the system glibc is too old.
# (aarch64-musl is intentionally absent: it fails to link on the
# arm runners and aarch64 login nodes are modern enough for gnu.)
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
# aarch64-unknown-linux-musl does not default to rust's self-contained
# linking (unlike x86_64), so musl targets need the musl C toolchain.
- name: Install musl toolchain
if: contains(matrix.target, 'musl')
run: sudo apt-get update -y && sudo apt-get install -y musl-tools
- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: stama
target: ${{ matrix.target }}
tar: unix
checksum: sha256
token: ${{ secrets.GITHUB_TOKEN }}
publish-crate:
needs: upload-assets
runs-on: ubuntu-latest
# Uses crates.io Trusted Publishing (OIDC) - no long-lived API token needed.
# One-time setup:
# 1. On crates.io: stama -> Settings -> Trusted Publishing -> add a
# GitHub config with repository "Gordi42/stama", workflow
# "release.yml", and environment "release".
# 2. In the GitHub repo settings, create an environment named "release".
environment: release
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}