-
Notifications
You must be signed in to change notification settings - Fork 8
66 lines (54 loc) · 2.48 KB
/
release.yml
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
name: Release
on: workflow_dispatch
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Release
# Prevent accidentally performing a release from a branch other than `main`.
if: github.ref == 'refs/heads/main'
runs-on: pub-hk-ubuntu-22.04-small
steps:
- name: Get token for GH application (Linguist)
uses: heroku/use-app-token-action@main
id: generate-token
with:
app_id: ${{ vars.LINGUIST_GH_APP_ID }}
private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
# Using the GH application token here will configure the local git config for this repo with credentials
# that can be used to make signed commits that are attributed to the GH application user
token: ${{ steps.generate-token.outputs.app_token }}
- name: Update Rust toolchain
run: rustup update
- name: Rust Cache
uses: Swatinem/[email protected]
- name: Install cargo-release
run: cargo install cargo-release
- name: Record new crate version
id: new-version
run: echo "version=$(yq '.workspace.package.version' Cargo.toml)" >> "${GITHUB_OUTPUT}"
- name: Check GitHub release does not already exist
run: |
if gh release view 'v${{ steps.new-version.outputs.version }}' --json url --jq '.url'; then
echo "Aborting since a GitHub release already exists for v${{ steps.new-version.outputs.version }}!" >&2
echo "If you are sure you want to recreate the release, delete the existing one first." >&2
exit 1
fi
- name: Extract changelog entry
id: changelog-entry
run: echo "content=$(awk '/^## \[${{ steps.new-version.outputs.version }}\]/{flag=1; next} /^## /{flag=0} flag' CHANGELOG.md)" >> "${GITHUB_OUTPUT}"
- name: Publish to crates.io
# cargo-release calculates the dependency graph for us, and also skips any already
# published packages - preventing overwrites and allowing for retrying the job.
run: cargo release publish --execute --no-confirm
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Create GitHub Release
uses: softprops/[email protected]
with:
token: ${{ steps.generate-token.outputs.app_token }}
tag_name: v${{ steps.new-version.outputs.version }}
body: ${{ steps.changelog-entry.outputs.content }}