bump #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: bump | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: "Version bump type" | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| workflow_call: | |
| inputs: | |
| bump: | |
| required: true | |
| type: string | |
| secrets: | |
| PLOTNIK_PAT: | |
| required: true | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 | |
| - name: Install tomato-toml | |
| uses: baptiste0928/cargo-install@b687c656bda5733207e629b50a22bf68974a0305 # v3.3.2 | |
| with: | |
| crate: tomato-toml | |
| locked: true | |
| - name: Calculate next version | |
| id: version | |
| run: | | |
| current=$(tomato get workspace.package.version Cargo.toml) | |
| IFS='.' read -r major minor patch <<< "$current" | |
| case "${{ inputs.bump }}" in | |
| major) next="$((major + 1)).0.0" ;; | |
| minor) next="$major.$((minor + 1)).0" ;; | |
| patch) next="$major.$minor.$((patch + 1))" ;; | |
| esac | |
| echo "current=$current" >> "$GITHUB_OUTPUT" | |
| echo "next=$next" >> "$GITHUB_OUTPUT" | |
| - name: Bump versions | |
| run: | | |
| next="${{ steps.version.outputs.next }}" | |
| tomato set workspace.package.version "$next" Cargo.toml | |
| tomato set workspace.dependencies.plotnik-core.version "$next" Cargo.toml | |
| tomato set workspace.dependencies.plotnik-langs.version "$next" Cargo.toml | |
| tomato set workspace.dependencies.plotnik-lib.version "$next" Cargo.toml | |
| # plotnik-cli has explicit plotnik-langs dep (default-features = false workaround) | |
| tomato set dependencies.plotnik-langs.version "$next" crates/plotnik-cli/Cargo.toml | |
| - name: Update lockfile | |
| run: cargo check --workspace | |
| - name: Create PR | |
| env: | |
| GH_TOKEN: ${{ secrets.PLOTNIK_PAT }} | |
| run: | | |
| next="${{ steps.version.outputs.next }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git checkout -b "bump/v$next" | |
| git add Cargo.toml Cargo.lock crates/plotnik-cli/Cargo.toml | |
| git commit -m "chore: Bump version to \`$next\`" | |
| git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}" | |
| git push -u origin "bump/v$next" | |
| gh pr create \ | |
| --title "chore: Bump version to \`$next\`" \ | |
| --body "Bump ${{ inputs.bump }} version: \`${{ steps.version.outputs.current }}\` → \`$next\`" |