|
| 1 | +name: Prepare Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + bump: |
| 7 | + description: 'Version bump type' |
| 8 | + required: true |
| 9 | + type: choice |
| 10 | + options: |
| 11 | + - patch |
| 12 | + - minor |
| 13 | + - major |
| 14 | + pre_release: |
| 15 | + description: 'Pre-release tag (e.g., alpha, beta, rc)' |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + |
| 23 | +jobs: |
| 24 | + prepare: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v4 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Install Rust |
| 34 | + uses: dtolnay/rust-toolchain@stable |
| 35 | + |
| 36 | + - name: Install git-cliff |
| 37 | + run: cargo install git-cliff |
| 38 | + |
| 39 | + - name: Determine new version |
| 40 | + id: version |
| 41 | + run: | |
| 42 | + current_version=$(grep '^version =' Cargo.toml | head -1 | cut -d'"' -f2) |
| 43 | + echo "Current version: $current_version" |
| 44 | +
|
| 45 | + IFS='.' read -r major minor patch <<< "$current_version" |
| 46 | +
|
| 47 | + case "${{ github.event.inputs.bump }}" in |
| 48 | + major) |
| 49 | + major=$((major + 1)) |
| 50 | + minor=0 |
| 51 | + patch=0 |
| 52 | + ;; |
| 53 | + minor) |
| 54 | + minor=$((minor + 1)) |
| 55 | + patch=0 |
| 56 | + ;; |
| 57 | + patch) |
| 58 | + patch=$((patch + 1)) |
| 59 | + ;; |
| 60 | + esac |
| 61 | +
|
| 62 | + new_version="$major.$minor.$patch" |
| 63 | +
|
| 64 | + if [ -n "${{ github.event.inputs.pre_release }}" ]; then |
| 65 | + new_version="$new_version-${{ github.event.inputs.pre_release }}" |
| 66 | + fi |
| 67 | +
|
| 68 | + echo "New version: $new_version" |
| 69 | + echo "new_version=$new_version" >> $GITHUB_OUTPUT |
| 70 | + echo "current_version=$current_version" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + - name: Update version in Cargo.toml files |
| 73 | + run: | |
| 74 | + # Update workspace version |
| 75 | + sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.new_version }}"/' Cargo.toml |
| 76 | +
|
| 77 | + # Update crate versions |
| 78 | + for crate in crates/*/Cargo.toml; do |
| 79 | + sed -i 's/^version = ".*"/version = "${{ steps.version.outputs.new_version }}"/' "$crate" |
| 80 | + done |
| 81 | +
|
| 82 | + # Update internal dependencies |
| 83 | + find . -name "Cargo.toml" -exec sed -i \ |
| 84 | + -e 's/redis-cloud = { version = ".*"/redis-cloud = { version = "${{ steps.version.outputs.new_version }}"/' \ |
| 85 | + -e 's/redis-enterprise = { version = ".*"/redis-enterprise = { version = "${{ steps.version.outputs.new_version }}"/' \ |
| 86 | + {} \; |
| 87 | +
|
| 88 | + - name: Generate changelog |
| 89 | + run: | |
| 90 | + git-cliff --config cliff.toml \ |
| 91 | + --tag v${{ steps.version.outputs.new_version }} \ |
| 92 | + --unreleased \ |
| 93 | + --output CHANGELOG.md |
| 94 | +
|
| 95 | + - name: Update Cargo.lock |
| 96 | + run: cargo update -w |
| 97 | + |
| 98 | + - name: Create release branch |
| 99 | + run: | |
| 100 | + git config user.name "github-actions[bot]" |
| 101 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 102 | +
|
| 103 | + branch_name="release/v${{ steps.version.outputs.new_version }}" |
| 104 | + git checkout -b "$branch_name" |
| 105 | +
|
| 106 | + git add -A |
| 107 | + git commit -m "chore: prepare release v${{ steps.version.outputs.new_version }}" |
| 108 | + git push origin "$branch_name" |
| 109 | +
|
| 110 | + - name: Create pull request |
| 111 | + uses: peter-evans/create-pull-request@v5 |
| 112 | + with: |
| 113 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 114 | + branch: release/v${{ steps.version.outputs.new_version }} |
| 115 | + title: "Release v${{ steps.version.outputs.new_version }}" |
| 116 | + body: | |
| 117 | + ## 🚀 Release v${{ steps.version.outputs.new_version }} |
| 118 | +
|
| 119 | + This PR prepares the release of version ${{ steps.version.outputs.new_version }}. |
| 120 | +
|
| 121 | + ### Changes |
| 122 | + - Version bumped from ${{ steps.version.outputs.current_version }} to ${{ steps.version.outputs.new_version }} |
| 123 | + - Updated CHANGELOG.md with latest changes |
| 124 | + - Updated Cargo.lock |
| 125 | +
|
| 126 | + ### Next Steps |
| 127 | + 1. Review the changes |
| 128 | + 2. Merge this PR to trigger the release |
| 129 | + 3. The tag-on-merge workflow will create the release tag |
| 130 | + 4. The release workflow will build and publish artifacts |
| 131 | +
|
| 132 | + --- |
| 133 | + *This PR was automatically created by the prepare-release workflow.* |
| 134 | + labels: | |
| 135 | + release |
| 136 | + automated |
0 commit comments