-
-
Notifications
You must be signed in to change notification settings - Fork 146
105 lines (92 loc) · 3.39 KB
/
prepare-release.yml
File metadata and controls
105 lines (92 loc) · 3.39 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
name: Prepare Release
concurrency:
group: prepare-release-${{ github.ref }}
cancel-in-progress: false
on:
workflow_dispatch:
inputs:
bump:
description: "Semantic version bump"
type: choice
options:
- patch
- minor
- major
default: patch
release:
description: "Manual release version (e.g. 1.2.3). Overrides bump."
type: string
required: false
default: ""
permissions:
contents: write
pull-requests: write
jobs:
prepare-release:
name: Prepare Release
runs-on: blacksmith-4vcpu-ubuntu-2404
env:
CARGO_TERM_COLOR: always
steps:
- name: Checkout (Full History)
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install cargo-edit
run: cargo install cargo-edit --locked
- name: Set Workspace Version (manual or bump)
shell: bash
run: |
set -euo pipefail
MANUAL_RELEASE="${{ inputs.release }}"
if [[ -n "${MANUAL_RELEASE}" ]]; then
# Validate SemVer (strict X.Y.Z numeric to align with repo conventions).
if [[ ! "${MANUAL_RELEASE}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Provided release '${MANUAL_RELEASE}' is not a valid SemVer (expected X.Y.Z)." >&2
exit 1
fi
echo "Setting workspace version to ${MANUAL_RELEASE} (manual)."
cargo set-version --workspace "${MANUAL_RELEASE}"
else
echo "Bumping workspace version by '${{ inputs.bump }}'."
cargo set-version --workspace --bump "${{ inputs.bump }}"
fi
- name: Read New Version
id: ver
shell: bash
run: |
set -euo pipefail
NEXT_VERSION=$(grep -m1 '^version = "' etl/Cargo.toml | sed -E 's/version = "([0-9]+\.[0-9]+\.[0-9]+)"/\1/')
if [[ -z "${NEXT_VERSION}" ]]; then
echo "Failed to parse bumped version from etl/Cargo.toml" >&2
exit 1
fi
echo "next=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
echo "Next version: ${NEXT_VERSION}"
- name: Install git-cliff
run: cargo install git-cliff --locked
- name: Generate CHANGELOG.md
env:
NEXT_VERSION: ${{ steps.ver.outputs.next }}
run: |
# Generate changelog with the new tag, containing only unreleased changes (difference from last tag)
# and prepend it to the existing changelog.
git cliff --config cliff.toml --tag "v${NEXT_VERSION}" --unreleased --prepend CHANGELOG.md
- name: Create Release Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: "chore(release): v${{ steps.ver.outputs.next }}"
title: "chore(release): v${{ steps.ver.outputs.next }}"
body: |
This PR prepares release v${{ steps.ver.outputs.next }}.
- Bumps workspace versions.
- Updates CHANGELOG.md with unreleased changes.
Merging this PR into `main` will trigger the release workflow which tags the commit, publishes Docker images, and creates the GitHub Release.
branch: release/v${{ steps.ver.outputs.next }}
base: main
labels: |
release
automated
delete-branch: true