-
-
Notifications
You must be signed in to change notification settings - Fork 2
139 lines (126 loc) · 4.79 KB
/
release-prep.yml
File metadata and controls
139 lines (126 loc) · 4.79 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
name: release-prep
on:
workflow_dispatch:
inputs:
crate:
description: "Target crate to bump (exclude fuzz)"
required: true
type: choice
options:
- all
- portable-network-archive
- pna
- libpna
default: portable-network-archive
level:
description: "Version level"
required: true
type: choice
options: [major, minor, patch]
default: patch
dependent_version:
description: "Update dependent versions?"
required: true
type: choice
options:
- fix # Upgrade only when previous requirement no longer matches
- upgrade # Always upgrade dependents
default: fix
jobs:
prepare:
name: Prepare release
runs-on: ubuntu-latest
permissions:
contents: write # push version bump commit
pull-requests: write # create draft PR
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
with:
toolchain: stable
cache-save-if: ${{ github.ref_name == github.event.repository.default_branch }}
- name: Install cargo-release
run: cargo install -f --git https://github.com/ChanTsune/cargo-release --branch workspace-enable-template-render-when-single-crate --locked cargo-release
- name: Compute next version and build temp release config
id: prep
shell: bash
env:
INPUT_CRATE: ${{ inputs.crate }}
run: |
set -euo pipefail
CONFIG=/tmp/release-config.toml
if [ "$INPUT_CRATE" != "all" ]; then
COMMIT_MSG=':bookmark: Bump {{crate_name}} version to {{version}}'
else
COMMIT_MSG=':bookmark: Bump version to {{version}}'
fi
printf 'pre-release-commit-message = "%s"\n' "$COMMIT_MSG" > "$CONFIG"
echo "config=$CONFIG" >> "$GITHUB_OUTPUT"
- name: Run cargo release (no tag/push)
env:
CARGO_TERM_COLOR: always
INPUT_CRATE: ${{ inputs.crate }}
INPUT_LEVEL: ${{ inputs.level }}
INPUT_DEPENDENT_VERSION: ${{ inputs.dependent_version }}
RELEASE_CONFIG: ${{ steps.prep.outputs.config }}
run: |
set -euo pipefail
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
if [ "$INPUT_CRATE" = "all" ]; then
PKG_ARGS=(--workspace)
else
PKG_ARGS=(-p "$INPUT_CRATE")
fi
cargo release \
"$INPUT_LEVEL" \
"${PKG_ARGS[@]}" \
--no-publish \
--no-push \
--no-tag \
--execute \
--no-confirm \
--exclude portable-network-archive-fuzz \
--exclude xtask \
--dependent-version "$INPUT_DEPENDENT_VERSION" \
--config "$RELEASE_CONFIG"
- name: Get new version
id: version
shell: bash
env:
INPUT_CRATE: ${{ inputs.crate }}
run: |
set -euo pipefail
if [ "$INPUT_CRATE" = "all" ]; then
TARGET_CRATE="portable-network-archive"
else
TARGET_CRATE="$INPUT_CRATE"
fi
NEW_VERSION=$(cargo metadata --format-version 1 --no-deps | jq -r --arg name "$TARGET_CRATE" '.packages[] | select(.name == $name) | .version')
echo "value=$NEW_VERSION" >> "$GITHUB_OUTPUT"
- name: Set PR branch name
id: branch
env:
INPUT_CRATE: ${{ inputs.crate }}
INPUT_LEVEL: ${{ inputs.level }}
NEW_VERSION: ${{ steps.version.outputs.value }}
run: |
BRANCH="release/${INPUT_CRATE}/${INPUT_LEVEL}-${NEW_VERSION}"
echo "name=$BRANCH" >> "$GITHUB_OUTPUT"
- name: Create draft PR
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.branch.outputs.name }}
title: "chore: prepare release ${{ inputs.crate }} ${{ steps.version.outputs.value }}"
body: |
Draft: release prep for `${{ inputs.crate }}` (${{ inputs.level }}).
- Version set to ${{ steps.version.outputs.value }}
- Dependent versions: ${{ inputs.dependent_version }}
- No tags or publishes; cargo-release performed pre-replacements.
draft: true
commit-message: "chore: prepare release ${{ inputs.crate }} ${{ steps.version.outputs.value }}"