-
Notifications
You must be signed in to change notification settings - Fork 4
116 lines (94 loc) · 3.46 KB
/
Copy pathprepare-release.yml
File metadata and controls
116 lines (94 loc) · 3.46 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
# .github/workflows/prepare-release.yml
name: Prepare Release
on:
workflow_dispatch:
inputs:
bump:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
prepare-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Calculate new version
id: version
run: |
# Get current version from Cargo.toml
CURRENT=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2)
# Calculate new version based on bump type
IFS='.' read -r major minor patch <<< "$CURRENT"
case "${{ inputs.bump }}" in
major)
major=$((major + 1))
minor=0
patch=0
;;
minor)
minor=$((minor + 1))
patch=0
;;
patch)
patch=$((patch + 1))
;;
esac
NEW_VERSION="$major.$minor.$patch"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT" >> $GITHUB_OUTPUT
echo "Bumping from $CURRENT to $NEW_VERSION"
- name: Update Cargo.toml
run: |
sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.new_version }}"/' Cargo.toml
- name: Update Cargo.lock
run: |
cargo update -p flux9s --precise ${{ steps.version.outputs.new_version }}
- name: Update CHANGELOG.md
run: |
VERSION="${{ steps.version.outputs.new_version }}"
DATE=$(date +%Y-%m-%d)
# Create the new changelog entry
cat > /tmp/changelog_entry.txt << EOF
## [$VERSION] - $DATE
### Added
-
### Changed
-
### Fixed
-
EOF
# Insert after the [Unreleased] line
sed -i "/^## \[Unreleased\]/r /tmp/changelog_entry.txt" CHANGELOG.md
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore: bump version to ${{ steps.version.outputs.new_version }}"
title: "Release v${{ steps.version.outputs.new_version }}"
body: |
## Release v${{ steps.version.outputs.new_version }}
This PR prepares the release for v${{ steps.version.outputs.new_version }}.
**Version bump:** ${{ steps.version.outputs.current_version }} → ${{ steps.version.outputs.new_version }} (${{ inputs.bump }})
**Changes in this PR:**
- ✅ Updated version in Cargo.toml
- ✅ Updated Cargo.lock
- ✅ Updated CHANGELOG.md with new version entry
**What happens after merge:**
1. ✅ PR gets merged to main
2. ✅ Tag `v${{ steps.version.outputs.new_version }}` is automatically created
3. ✅ Release workflow builds binaries for all platforms
4. ✅ Publishes to crates.io
5. ✅ Creates GitHub release with artifacts
6. ✅ Updates Homebrew formula
**Please update the CHANGELOG.md** with actual changes before merging!
branch: release-v${{ steps.version.outputs.new_version }}
delete-branch: true
labels: release