-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (125 loc) · 5.06 KB
/
bump-version-rust.yml
File metadata and controls
145 lines (125 loc) · 5.06 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: bump version / rust
on:
workflow_call:
inputs:
package:
description: Cargo package
required: true
type: string
level:
# https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md#bump-level
description: Bump level
required: true
type: string
secrets:
APP_ID:
description: GitHub App installation ID
required: true
APP_PRIVATE_KEY:
description: GitHub App private key
required: true
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: -D warnings
jobs:
prepare_next_release:
name: prepare next release
runs-on: ubuntu-latest
steps:
- name: Validate bump level
env:
INPUTS_LEVEL: ${{ inputs.level }}
run: |
case "${INPUTS_LEVEL}" in
major|minor|patch|release|rc|beta|alpha) ;;
*)
echo "::error::Invalid level '${INPUTS_LEVEL}' (expected major, minor, patch, release, rc, beta, or alpha)."
exit 1
;;
esac
- id: generate_token
name: Generate a GitHub App token
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
token: ${{ steps.generate_token.outputs.token }}
ref: main
fetch-depth: 0
persist-credentials: false
- name: Add Toolbox Envy to PATH
uses: EarthmanMuons/toolbox-envy/.github/actions/add-to-path@main
with:
include_bins: |
common
rust
- name: Install stable Rust toolchain
uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
with:
toolchain: stable
- name: Cache dependencies
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5
with:
shared-key: stable-ubuntu-latest
timeout-minutes: 5
- name: Install cargo-release
uses: taiki-e/install-action@7e574ed8bb89811282a11aecb3fe1d043bf5bf0e
with:
tool: cargo-release
- name: Update cargo dependencies for package ${{ inputs.package }}
env:
INPUTS_PACKAGE: ${{ inputs.package }}
run: cargo update --package "${INPUTS_PACKAGE}"
- name: Bump ${{ inputs.level }} version for package ${{ inputs.package }}
env:
INPUTS_PACKAGE: ${{ inputs.package }}
INPUTS_LEVEL: ${{ inputs.level }}
run: cargo release version -v --execute --no-confirm --package "${INPUTS_PACKAGE}" "${INPUTS_LEVEL}"
- name: Perform pre-release replacements
env:
INPUTS_PACKAGE: ${{ inputs.package }}
run: cargo release replace -v --execute --no-confirm --package "${INPUTS_PACKAGE}"
- name: Fix up CHANGELOG formatting
run: npx --yes prettier@latest --color --prose-wrap always --write -- **/CHANGELOG.md
- id: version
name: Get the new release version
env:
INPUTS_PACKAGE: ${{ inputs.package }}
run: |
echo "release_version=$(get-project-version "$INPUTS_PACKAGE")" >>"$GITHUB_OUTPUT"
- id: cpr
name: Create pull request
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0
with:
token: ${{ steps.generate_token.outputs.token }}
branch: release/bump-version
branch-suffix: timestamp
commit-message: Release ${{ inputs.package }} v${{ steps.version.outputs.release_version }}
title: Prepare the ${{ inputs.package }} v${{ steps.version.outputs.release_version }} ${{ inputs.level }} release
body: |-
This PR was automatically created by the [bump-version](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow, which ran the following commands:
```
$ cargo update --package ${{ inputs.package }}
$ cargo release version --execute --package ${{ inputs.package }} ${{ inputs.level }}
$ cargo release replace --execute --package ${{ inputs.package }}
$ prettier --prose-wrap always --write -- **/CHANGELOG.md
```
**Please review the submitted changes.**
Once this PR is merged into the _main_ branch, an automated process will tag the commit, which triggers the next step in the release process for this package.
- name: Annotate workflow run with PR URL
env:
INPUTS_PACKAGE: ${{ inputs.package }}
PULL_REQUEST_URL: ${{ steps.cpr.outputs.pull-request-url }}
RELEASE_VERSION: ${{ steps.version.outputs.release_version }}
run: |
set -euo pipefail
{
echo "### :shipit: Opened pull request for ${INPUTS_PACKAGE} release v${RELEASE_VERSION}:"
echo
echo "- ${PULL_REQUEST_URL}"
} >>"$GITHUB_STEP_SUMMARY"