-
Notifications
You must be signed in to change notification settings - Fork 2
119 lines (100 loc) · 2.99 KB
/
release.yml
File metadata and controls
119 lines (100 loc) · 2.99 KB
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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
env:
RUSTFLAGS: "-D warnings"
jobs:
check:
name: CI checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Rust checks
run: cargo fmt --check && cargo clippy -- -D warnings && cargo build && cargo test
build:
name: Build ${{ matrix.target }}
needs: check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Package artifact
shell: bash
run: |
tag="${GITHUB_REF#refs/tags/}"
name="bugatti-${tag}-${{ matrix.target }}"
mkdir -p "dist/${name}"
cp "target/${{ matrix.target }}/release/bugatti" "dist/${name}/"
cd dist
tar czf "${name}.tar.gz" "${name}"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: bugatti-${{ matrix.target }}
path: dist/*.tar.gz
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz > checksums-sha256.txt
- name: Extract changelog for release
id: changelog
run: |
tag="${GITHUB_REF#refs/tags/}"
version="${tag#v}"
# Extract the section between this version's heading and the next heading
notes=$(awk -v ver="$version" '
/^## \[/ {
if (found) exit
if ($0 ~ "\\[" ver "\\]") found=1; next
}
found { print }
' CHANGELOG.md)
# Fail if we got nothing — forces you to update CHANGELOG.md before tagging
if [ -z "$notes" ]; then
echo "::error::No CHANGELOG.md entry found for version ${version}"
exit 1
fi
# Write to file to avoid quoting issues
echo "$notes" > release-notes.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "${tag}" \
--title "${tag}" \
--notes-file release-notes.md \
--draft \
artifacts/*.tar.gz \
artifacts/checksums-sha256.txt