Update versions and create release PR #262
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
| --- | |
| # This workflow is triggered manually to increment version numbers and open a | |
| # release PR. When that PR is merged, a release is created (see `release.yaml`). | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump_type: | |
| description: Version bump type | |
| required: true | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| default: patch | |
| name: Update versions and create release PR | |
| jobs: | |
| version: | |
| name: Bump version and create release PR | |
| runs-on: ubuntu-latest | |
| environment: version-bump | |
| steps: | |
| # See: https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens | |
| - uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1 | |
| id: generate_token | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| # Fetch all history/tags (needed to compute versions) | |
| fetch-depth: 0 | |
| - uses: cachix/install-nix-action@7be5dee1421f63d07e71ce6e0a9f8a4b07c2a487 # v31.6.1 | |
| with: | |
| github_access_token: ${{ secrets.GITHUB_TOKEN }} | |
| extra_nix_config: | | |
| extra-experimental-features = nix-command flakes | |
| accept-flake-config = true | |
| - name: Get old version number | |
| id: old_cargo_metadata | |
| run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT" | |
| - name: Increment `Cargo.toml` version | |
| run: nix run .#make-release-commit -- ${{ inputs.bump_type }} | |
| - name: Get new version number | |
| id: new_cargo_metadata | |
| run: echo "version=$(nix run .#get-crate-version)" >> "$GITHUB_OUTPUT" | |
| - name: Create release PR | |
| id: release_pr | |
| uses: peter-evans/create-pull-request@4e1beaa7521e8b457b572c090b25bd3db56bf1c5 # v5.0.3 | |
| with: | |
| # PRs created with the default `secrets.GITHUB_TOKEN` won't | |
| # trigger `pull_request` workflows, so regular CI won't run either. | |
| # See: https://github.com/orgs/community/discussions/65321 | |
| token: ${{ steps.generate_token.outputs.token }} | |
| branch: release/${{ steps.new_cargo_metadata.outputs.version }} | |
| delete-branch: true | |
| base: main | |
| title: Release version ${{ steps.new_cargo_metadata.outputs.version }} | |
| body: | | |
| Update version to ${{ steps.new_cargo_metadata.outputs.version }} with [cargo-release](https://github.com/crate-ci/cargo-release). | |
| Merge this PR to build and publish a new release. | |
| labels: release |