chore(deps): bump the actions group across 2 directories with 1 updat… #177
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: Update package version | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Specify version" | |
| required: false | |
| type: string | |
| default: "" | |
| bump: | |
| description: "Perform bump" | |
| required: false | |
| type: string | |
| default: "" | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| FORCE_COLOR: "3" | |
| jobs: | |
| rooster: | |
| name: Rooster update | |
| runs-on: ubuntu-slim | |
| # only allow on main branch | |
| if: | |
| # prettier-ignore | |
| github.ref == 'refs/heads/main' && github.repository_owner == 'usnistgov' | |
| environment: | |
| name: pull-request | |
| steps: | |
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup-cached-uv-and-python | |
| with: | |
| python-version-file: ".python-version" | |
| cache-dependency-path: requirements/lock/uvx-tools.txt | |
| - name: Get current package version | |
| id: version | |
| run: | | |
| echo "current_version=$(uv version --short --color=never)" >> "$GITHUB_OUTPUT" | |
| - name: Rooster cache | |
| id: numba-cache-restore | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | |
| with: | |
| path: | | |
| ${{ github.workspace }}/.cache | |
| ${{ github.workspace }}\.cache | |
| key: | |
| rooster-cache|${{ runner.os }}|${{ runner.arch }}|${{ | |
| steps.version.outputs.current_version }} | |
| - name: Bump version with rooster | |
| id: changed | |
| env: | |
| version: ${{ inputs.version || '' }} | |
| bump: ${{ inputs.bump || '' }} | |
| event_name: ${{ github.event_name }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # rooster bump version | |
| if [ "$version" != "" ]; then | |
| options="--version=${version}" | |
| elif [ "$bump" != "" ]; then | |
| options="--bump=${bump}" | |
| else | |
| options="" | |
| fi | |
| # run rooster | |
| uvx -crequirements/lock/uvx-tools.txt rooster release "$options" || true | |
| if ! git diff --quiet -- pyproject.toml; then | |
| changed='true' | |
| uv lock | |
| else | |
| changed='false' | |
| fi | |
| echo "changed=$changed" >> "$GITHUB_OUTPUT" | |
| shell: bash -euxo pipefail {0} | |
| - id: message | |
| if: steps.changed.outputs.changed == 'true' | |
| env: | |
| current_version: ${{ steps.version.outputs.current_version }} | |
| run: | | |
| import os | |
| import tomllib | |
| from pathlib import Path | |
| project = tomllib.loads(Path("pyproject.toml").read_text())["project"] | |
| current_version = os.getenv("current_version") | |
| new_version = project["version"] | |
| package_name = project["name"] | |
| title = f"chore(bump): bump {package_name} from {current_version} to {new_version}" | |
| # if you'd like to by default skip ci | |
| # commit_message = f"{title} [skip ci]" | |
| # if you'd like to by default not skip ci | |
| commit_message = title | |
| # if want to use new version release branch | |
| branch = f"release/v{new_version}" | |
| # if want to just have one release branch going | |
| # branch = f"release/next-release" | |
| with open(os.getenv("GITHUB_OUTPUT"), "a") as f: | |
| f.write(f"{title=:s}\n") | |
| f.write(f"{commit_message=:s}\n") | |
| f.write(f"{branch=:s}\n") | |
| shell: python | |
| - name: Create pull request | |
| if: steps.changed.outputs.changed == 'true' | |
| id: cpr | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| with: | |
| # use this if want to force skip workflows. You'll need to close and reopen. | |
| # token: ${{ secrets.GITHUB_TOKEN }} | |
| token: ${{ secrets.PAT }} | |
| add-paths: . | |
| commit-message: ${{ steps.message.outputs.commit_message }} | |
| title: ${{ steps.message.outputs.title }} | |
| labels: | | |
| release | |
| branch: ${{ steps.message.outputs.branch }} | |
| # optionally use draft to skip ci | |
| # draft: true | |
| delete-branch: true | |
| body: | | |
| This is an autogenerated PR. Use this to bump the package version. | |
| You may need to push an empty commit to restart ci (or close and open) | |
| - name: Pull request info | |
| if: ${{ steps.cpr.outputs.pull-request-number }} | |
| env: | |
| NUMBER: ${{ steps.cpr.outputs.pull-request-number }} | |
| URL: ${{ steps.cpr.outputs.pull-request-url }} | |
| OPERATION: ${{ steps.cpr.outputs.pull-request-operation }} | |
| SHA: ${{ steps.cpr.outputs.pull-request-sha }} | |
| BRANCH: ${{ steps.cpr.outputs.pull-request-branch }} | |
| VERIFIED: ${{ steps.cpr.outputs.pull-request-commits-verified }} | |
| run: | | |
| echo "Pull Request Number - $NUMBER" | |
| echo "Pull Request URL - $URL" | |
| echo "Pull Request Operation - $OPERATION" | |
| echo "Pull Request SHA - $SHA" | |
| echo "Pull Request BRANCH - $BRANCH" | |
| echo "Pull Request VERIFIED - $VERIFIED" | |
| # If want to automerge, set draft to false above, and uncomment below. | |
| - name: automerge | |
| if: ${{ steps.cpr.outputs.pull-request-number }} | |
| env: | |
| NUMBER: ${{ steps.cpr.outputs.pull-request-number }} | |
| # Need PAT if want to start other actions. Use GITHUB_TOKEN if not. | |
| GH_TOKEN: ${{ secrets.PAT }} | |
| run: | | |
| gh pr merge -m --auto "$NUMBER" |