|
| 1 | +name: Bump Version |
| 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 | + |
| 15 | + workflow_call: |
| 16 | + inputs: |
| 17 | + bump: |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + |
| 21 | +jobs: |
| 22 | + bump: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: write |
| 26 | + pull-requests: write |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Install tomato-toml |
| 32 | + run: cargo install tomato-toml --locked |
| 33 | + |
| 34 | + - name: Calculate next version |
| 35 | + id: version |
| 36 | + run: | |
| 37 | + current=$(tomato get workspace.package.version Cargo.toml) |
| 38 | + IFS='.' read -r major minor patch <<< "$current" |
| 39 | + case "${{ inputs.bump }}" in |
| 40 | + major) next="$((major + 1)).0.0" ;; |
| 41 | + minor) next="$major.$((minor + 1)).0" ;; |
| 42 | + patch) next="$major.$minor.$((patch + 1))" ;; |
| 43 | + esac |
| 44 | + echo "current=$current" >> "$GITHUB_OUTPUT" |
| 45 | + echo "next=$next" >> "$GITHUB_OUTPUT" |
| 46 | +
|
| 47 | + - name: Bump versions |
| 48 | + run: | |
| 49 | + next="${{ steps.version.outputs.next }}" |
| 50 | + tomato set workspace.package.version "$next" Cargo.toml |
| 51 | + tomato set workspace.dependencies.plotnik-core.version "$next" Cargo.toml |
| 52 | + tomato set workspace.dependencies.plotnik-langs.version "$next" Cargo.toml |
| 53 | + tomato set workspace.dependencies.plotnik-lib.version "$next" Cargo.toml |
| 54 | + # plotnik-cli has explicit plotnik-langs dep (default-features = false workaround) |
| 55 | + tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-cli/Cargo.toml |
| 56 | +
|
| 57 | + - name: Update lockfile |
| 58 | + run: cargo check --workspace |
| 59 | + |
| 60 | + - name: Create PR |
| 61 | + env: |
| 62 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + run: | |
| 64 | + next="${{ steps.version.outputs.next }}" |
| 65 | + git config user.name "github-actions[bot]" |
| 66 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 67 | + git checkout -b "bump/v$next" |
| 68 | + git add Cargo.toml Cargo.lock crates/plotnik-cli/Cargo.toml |
| 69 | + git commit -m "chore: Bump version to \`$next\`" |
| 70 | + git push -u origin "bump/v$next" |
| 71 | + gh pr create \ |
| 72 | + --title "chore: Bump version to \`$next\`" \ |
| 73 | + --body "Bump ${{ inputs.bump }} version: \`${{ steps.version.outputs.current }}\` → \`$next\`" |
0 commit comments