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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: release
# Triggered by pushing a version tag, e.g. `git tag v0.2.1 && git push --tags`.
# Builds one binary per target, packages it as a tarball, and attaches the
# tarballs (plus SHA-256 checksums) to a GitHub Release.
#
# Publishing to crates.io is intentionally left manual — run `cargo publish`
# yourself once you're happy with a release. To automate it later, add a
# CARGO_REGISTRY_TOKEN secret and uncomment the `publish-crates` job below.
on:
push:
tags:
permissions:
contents: write
jobs:
build:
name: build / ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Both Darwin targets cross-compile from the ARM `macos-latest`
# pool. GitHub's Intel `macos-13` pool has long queues on public
# repos, and Apple's own clang/ld can emit for either arch with
# no extra tooling — `rustup target add` (done by the toolchain
# step below) just fetches the right prebuilt libstd.
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
linker: aarch64-linux-gnu-gcc
apt: gcc-aarch64-linux-gnu
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install cross-linker (aarch64 linux only)
if: matrix.apt
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.apt }}
mkdir -p .cargo
{
echo "[target.${{ matrix.target }}]"
echo "linker = \"${{ matrix.linker }}\""
} >> .cargo/config.toml
- name: Build
run: cargo build --release --target ${{ matrix.target }} --locked
- name: Package
id: pkg
shell: bash
run: |
VERSION="${GITHUB_REF_NAME#v}"
NAME="git-nav-${VERSION}-${{ matrix.target }}"
mkdir -p "dist/${NAME}"
cp "target/${{ matrix.target }}/release/git-nav" "dist/${NAME}/"
cp README.md LICENSE-MIT LICENSE-APACHE "dist/${NAME}/"
( cd dist && tar -czf "${NAME}.tar.gz" "${NAME}" )
( cd dist && shasum -a 256 "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256" )
echo "asset=dist/${NAME}.tar.gz" >> "$GITHUB_OUTPUT"
echo "checksum=dist/${NAME}.tar.gz.sha256" >> "$GITHUB_OUTPUT"
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.target }}
path: |
${{ steps.pkg.outputs.asset }}
${{ steps.pkg.outputs.checksum }}
retention-days: 7
release:
name: publish github release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
files: |
dist/*.tar.gz
dist/*.sha256
generate_release_notes: true
fail_on_unmatched_files: true
# ---------------------------------------------------------------------------
# Uncomment once you've added a CARGO_REGISTRY_TOKEN secret in
# repo Settings → Secrets and variables → Actions.
# ---------------------------------------------------------------------------
# publish-crates:
# name: publish to crates.io
# needs: release
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v7
# - uses: dtolnay/rust-toolchain@stable
# - run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}