-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (62 loc) · 1.92 KB
/
release.yml
File metadata and controls
75 lines (62 loc) · 1.92 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
name: Release
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@v2
with:
tool: just
- name: Get version from tag
id: tag_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_ENV"
- name: Check Cargo.toml version
run: |
CARGO_VERSION="$(awk '
$0 == "[workspace.package]" { in_section = 1; next }
in_section && $1 == "version" {
gsub(/"/, "", $3)
print $3
exit
}
in_section && /^\[/ { exit }
' Cargo.toml)"
if [ -z "$CARGO_VERSION" ]; then
echo "Error: failed to parse workspace.package.version from Cargo.toml"
exit 1
fi
echo "Cargo version: $CARGO_VERSION"
echo "Tag version: ${{ env.VERSION }}"
if [ "$CARGO_VERSION" != "${{ env.VERSION }}" ]; then
echo "Error: Cargo.toml version ($CARGO_VERSION) does not match tag version (${{ env.VERSION }})"
exit 1
fi
- name: Generate Changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --verbose --latest --strip header
env:
OUTPUT: CHANGELOG.md
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.git-cliff.outputs.content }}
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}
- name: Publish to crates.io
run: just publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}