-
Notifications
You must be signed in to change notification settings - Fork 20
174 lines (150 loc) · 5.26 KB
/
Copy pathversion.yml
File metadata and controls
174 lines (150 loc) · 5.26 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: version management
on:
workflow_dispatch:
inputs:
action:
type: choice
description: What do you want to do?
required: true
options:
- bump-version # 1.2.3 -> 1.2.4
- start-prerelease # 1.2.3 -> 1.3.0-beta.1
- bump-prerelease # beta.5 -> beta.6
- transition-prerelease # beta.5 -> rc.1
- finalize # 1.3.0-rc.2 -> 1.3.0
level:
type: choice
description: Version bump level (required for bump-version / start-prerelease)
required: false
options: [patch, minor, major]
stage:
type: choice
description: Prerelease stage (required for start-prerelease / transition-prerelease)
required: false
options: [alpha, beta, rc]
permissions:
contents: write
pull-requests: write
jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Validate inputs
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
STAGE="${{ github.event.inputs.stage }}"
case "$ACTION" in
bump-version)
[ -n "$LEVEL" ] || { echo "level is required"; exit 1; }
;;
start-prerelease)
[ -n "$LEVEL" ] && [ -n "$STAGE" ] || {
echo "level and stage are required"
exit 1
}
;;
bump-prerelease)
;;
transition-prerelease)
[ -n "$STAGE" ] || { echo "stage is required"; exit 1; }
;;
finalize)
;;
*)
echo "Invalid action"
exit 1
;;
esac
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get current version
id: current_version
uses: mozilla-ai/cargo-goosectl/actions/current-version@v1
with:
force-single-version: true
- name: Compute cargo-goosectl args
id: goose_args
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
STAGE="${{ github.event.inputs.stage }}"
case "$ACTION" in
bump-version)
ARGS="bump version $LEVEL"
;;
start-prerelease)
ARGS="bump version $LEVEL $STAGE"
;;
bump-prerelease)
ARGS="bump prerelease"
;;
transition-prerelease)
ARGS="bump prerelease $STAGE"
;;
finalize)
ARGS="bump release"
;;
*)
echo "Invalid action"
exit 1
;;
esac
echo "args=$ARGS" >> "$GITHUB_OUTPUT"
- name: Bump version
uses: mozilla-ai/cargo-goosectl/actions/cargo-goosectl@v1
with:
args: ${{ steps.goose_args.outputs.args }}
- name: Get new version
id: new_version
uses: mozilla-ai/cargo-goosectl/actions/current-version@v1
with:
force-single-version: true
- name: Abort if version did not change
run: |
if [ "${{ steps.current_version.outputs.version }}" = \
"${{ steps.new_version.outputs.version }}" ]; then
echo "Version did not change; aborting"
exit 1
fi
- name: Update Cargo.lock
run: cargo generate-lockfile
- name: Generate labels
id: labels
run: |
ACTION="${{ github.event.inputs.action }}"
LEVEL="${{ github.event.inputs.level }}"
IS_PRE="${{ steps.new_version.outputs.is_prerelease }}"
PRE="${{ steps.new_version.outputs.pre }}"
LABELS="version-bump\nauto-generated\n$ACTION"
if [ "$IS_PRE" = "true" ]; then
LABELS="$LABELS\nprerelease\n$PRE"
else
[ -n "$LEVEL" ] && LABELS="$LABELS\n$LEVEL"
fi
echo "labels<<EOF" >> "$GITHUB_OUTPUT"
echo -e "$LABELS" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "version: bump version 🚀 ${{ steps.new_version.outputs.version }}"
title: "version: Version Bump 🚀 ${{ steps.new_version.outputs.version }}"
body: |
Version bumped from ${{ steps.current_version.outputs.version }}
to ${{ steps.new_version.outputs.version }}.
### 🔄 Changes
- 📝 Updated version in Cargo.toml
- 🔒 Updated Cargo.lock
✨ This PR was automatically generated by the Version Management workflow ✨

branch: version/bump-${{ github.run_id }}
base: main
delete-branch: true
add-paths: |
Cargo.lock
**/Cargo.toml
labels: ${{ steps.labels.outputs.labels }}