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
name: Release
# Tagging `vX.Y.Z` builds cross-platform binaries and publishes a GitHub Release
# with notes drawn from CHANGELOG.md. No manual release steps required.
on:
push:
tags:
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (unix)
if: runner.os != 'Windows'
run: |
bin="target/${{ matrix.target }}/release/killer"
tar -czf "killer-${{ matrix.target }}.tar.gz" -C "$(dirname "$bin")" killer
shasum -a 256 "killer-${{ matrix.target }}.tar.gz" > "killer-${{ matrix.target }}.tar.gz.sha256"
- name: Package (windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$bin = "target/${{ matrix.target }}/release/killer.exe"
Compress-Archive -Path $bin -DestinationPath "killer-${{ matrix.target }}.zip"
(Get-FileHash "killer-${{ matrix.target }}.zip" -Algorithm SHA256).Hash | Out-File "killer-${{ matrix.target }}.zip.sha256"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: killer-${{ matrix.target }}
path: |
killer-${{ matrix.target }}.*
release:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Extract release notes from CHANGELOG
id: notes
run: |
version="${GITHUB_REF_NAME#v}"
awk -v v="$version" '
$0 ~ "^## \\[" v "\\]" {flag=1; next}
/^## \[/ {flag=0}
flag {print}
' CHANGELOG.md > release-notes.md
if [ ! -s release-notes.md ]; then echo "Release $GITHUB_REF_NAME" > release-notes.md; fi
- name: Publish GitHub Release
uses: softprops/action-gh-release@v2
with:
body_path: release-notes.md
files: dist/*
generate_release_notes: false