-
Notifications
You must be signed in to change notification settings - Fork 26
99 lines (80 loc) · 2.85 KB
/
release.yml
File metadata and controls
99 lines (80 loc) · 2.85 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
name: Release
on:
workflow_dispatch:
branches:
- master
inputs:
release_level:
description: 'Release level'
required: true
type: choice
options:
- alpha
- beta
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest-64
permissions:
contents: write # Required for pushing commits and tags
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
persist-credentials: true
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-release
run: cargo install cargo-release
- name: Install git-cliff
run: cargo install git-cliff
- name: Check compilation
run: cargo check --all-features
- name: Get GitHub App token (for bpx-api-client)
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.BACKPACK_CI_APP_ID }}
private-key: ${{ secrets.BACKPACK_CI_APP_PRIVATE_KEY }}
owner: backpack-exchange
repositories: |
bpx-api-client
- name: Configure git (disable signing in CI)
run: |
git config --global user.email "bot@backpack.exchange"
git config --global user.name "backpack-exchange[bot]"
git config --global credential.helper cache
git config --global commit.gpgsign false
- name: Clone bpx-api-client repository
env:
APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
git clone "https://x-access-token:${APP_TOKEN}@github.com/backpack-exchange/bpx-api-client.git" bpx-api-client
- name: Release
env:
APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
cd bpx-api-client
git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/backpack-exchange/bpx-api-client.git"
# Run cargo release to update the version
cargo release version ${{ github.event.inputs.release_level }} --execute --no-confirm
# Extract the new version from Cargo.toml
NEW_VERSION=$(grep "^version" Cargo.toml | head -1 | cut -d'"' -f2)
# Generate the CHANGELOG
git tag v${NEW_VERSION}
git-cliff -o CHANGELOG.md
git tag --delete v${NEW_VERSION}
# Commit the changes
git add -A
git commit -m "chore(release) v${NEW_VERSION}"
# Tag the release
git tag v${NEW_VERSION}
# Push
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD || echo master)"
git push origin "HEAD:${CURRENT_BRANCH}" --tags
# Publish
cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}