|
| 1 | +# .github/workflows/prepare-release.yml |
| 2 | +name: Prepare Release |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + bump: |
| 8 | + description: "Version bump type" |
| 9 | + required: true |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + |
| 16 | +jobs: |
| 17 | + prepare-release: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Install Rust |
| 25 | + uses: dtolnay/rust-toolchain@stable |
| 26 | + |
| 27 | + - name: Calculate new version |
| 28 | + id: version |
| 29 | + run: | |
| 30 | + # Get current version from Cargo.toml |
| 31 | + CURRENT=$(grep '^version = ' Cargo.toml | head -1 | cut -d'"' -f2) |
| 32 | +
|
| 33 | + # Calculate new version based on bump type |
| 34 | + IFS='.' read -r major minor patch <<< "$CURRENT" |
| 35 | +
|
| 36 | + case "${{ inputs.bump }}" in |
| 37 | + major) |
| 38 | + major=$((major + 1)) |
| 39 | + minor=0 |
| 40 | + patch=0 |
| 41 | + ;; |
| 42 | + minor) |
| 43 | + minor=$((minor + 1)) |
| 44 | + patch=0 |
| 45 | + ;; |
| 46 | + patch) |
| 47 | + patch=$((patch + 1)) |
| 48 | + ;; |
| 49 | + esac |
| 50 | +
|
| 51 | + NEW_VERSION="$major.$minor.$patch" |
| 52 | + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT |
| 53 | + echo "current_version=$CURRENT" >> $GITHUB_OUTPUT |
| 54 | + echo "Bumping from $CURRENT to $NEW_VERSION" |
| 55 | +
|
| 56 | + - name: Update Cargo.toml |
| 57 | + run: | |
| 58 | + sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.new_version }}"/' Cargo.toml |
| 59 | +
|
| 60 | + - name: Update Cargo.lock |
| 61 | + run: | |
| 62 | + cargo update -p flux9s --precise ${{ steps.version.outputs.new_version }} |
| 63 | +
|
| 64 | + - name: Update CHANGELOG.md |
| 65 | + run: | |
| 66 | + VERSION="${{ steps.version.outputs.new_version }}" |
| 67 | + DATE=$(date +%Y-%m-%d) |
| 68 | +
|
| 69 | + # Create the new changelog entry |
| 70 | + cat > /tmp/changelog_entry.txt << EOF |
| 71 | +
|
| 72 | + ## [$VERSION] - $DATE |
| 73 | +
|
| 74 | + ### Added |
| 75 | + - |
| 76 | +
|
| 77 | + ### Changed |
| 78 | + - |
| 79 | +
|
| 80 | + ### Fixed |
| 81 | + - |
| 82 | + EOF |
| 83 | +
|
| 84 | + # Insert after the [Unreleased] line |
| 85 | + sed -i "/^## \[Unreleased\]/r /tmp/changelog_entry.txt" CHANGELOG.md |
| 86 | +
|
| 87 | + - name: Create Pull Request |
| 88 | + uses: peter-evans/create-pull-request@v5 |
| 89 | + with: |
| 90 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 91 | + commit-message: "chore: bump version to ${{ steps.version.outputs.new_version }}" |
| 92 | + title: "Release v${{ steps.version.outputs.new_version }}" |
| 93 | + body: | |
| 94 | + ## Release v${{ steps.version.outputs.new_version }} |
| 95 | +
|
| 96 | + This PR prepares the release for v${{ steps.version.outputs.new_version }}. |
| 97 | +
|
| 98 | + **Version bump:** ${{ steps.version.outputs.current_version }} → ${{ steps.version.outputs.new_version }} (${{ inputs.bump }}) |
| 99 | +
|
| 100 | + **Changes in this PR:** |
| 101 | + - ✅ Updated version in Cargo.toml |
| 102 | + - ✅ Updated Cargo.lock |
| 103 | + - ✅ Updated CHANGELOG.md with new version entry |
| 104 | +
|
| 105 | + **What happens after merge:** |
| 106 | + 1. ✅ PR gets merged to main |
| 107 | + 2. ✅ Tag `v${{ steps.version.outputs.new_version }}` is automatically created |
| 108 | + 3. ✅ Release workflow builds binaries for all platforms |
| 109 | + 4. ✅ Publishes to crates.io |
| 110 | + 5. ✅ Creates GitHub release with artifacts |
| 111 | + 6. ✅ Updates Homebrew formula |
| 112 | +
|
| 113 | + **Please update the CHANGELOG.md** with actual changes before merging! |
| 114 | + branch: release-v${{ steps.version.outputs.new_version }} |
| 115 | + delete-branch: true |
| 116 | + labels: release |
0 commit comments