create-release-pr #10
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: create-release-pr | |
| run-name: create-release-pr | |
| description: | | |
| Create a release PR for a project in the repository | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| type: string | |
| required: true | |
| description: | | |
| Version to prep for release (ex. `0.1.0`, `0.1.0-rc.0`) | |
| permissions: | |
| contents: none | |
| jobs: | |
| create-release-pr: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| id-token: write | |
| pull-requests: write | |
| contents: write | |
| issues: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| # Install Rust deps | |
| - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8 | |
| - uses: taiki-e/cache-cargo-install-action@5c9abe9a3f79d831011df7c47177debbeb320405 # v2.1.2 | |
| with: | |
| tool: git-cliff | |
| - name: Cache npm install | |
| id: cache-node-modules | |
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 | |
| with: | |
| key: node-modules-dev-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json') }} | |
| path: | | |
| node_modules | |
| - name: Install debug NPM packages | |
| run: | | |
| npm install -D | |
| - name: Gather project metadata | |
| id: project-meta | |
| env: | |
| NEXT_VERSION: ${{ inputs.version }} | |
| shell: bash | |
| run: | | |
| if [[ $NEXT_VERSION == v* ]]; then | |
| echo "::error::next version [$NEXT_VERSION] starts with 'v' -- enter only the semver version (ex. '0.1.0', not 'v0.1.0')"; | |
| exit 1; | |
| fi | |
| export PROJECT_DIR=$PWD; | |
| export CURRENT_VERSION=$(node -e "process.stdout.write(require(process.env.PROJECT_DIR + '/package.json').version)"); | |
| echo -e "project-dir=$PROJECT_DIR" | |
| echo -e "current-version=$CURRENT_VERSION" | |
| echo -e "next-version=$NEXT_VERSION" | |
| echo -e "project-dir=$PROJECT_DIR" >> $GITHUB_OUTPUT | |
| echo -e "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo -e "next-version=$NEXT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Ensure next version is after current | |
| run: | | |
| IS_AFTER=$(node scripts/semver-lt.mjs ${{ steps.project-meta.outputs.current-version }} ${{ steps.project-meta.outputs.next-version }}); | |
| if [ "$IS_AFTER" == "false" ]; then \ | |
| echo "::error::project [componentize-js] next version [${{ steps.project-meta.outputs.next-version }}] is not after current version [${{ steps.project-meta.outputs.current-version }}]"; | |
| exit 1; | |
| fi | |
| # Set project version | |
| - name: Set project version | |
| working-directory: ${{ steps.project-meta.outputs.project-dir }} | |
| shell: bash | |
| run: | | |
| npm pkg set version=${{ steps.project-meta.outputs.next-version }}; | |
| sed -i \ | |
| "s/version('${{ steps.project-meta.outputs.current-version }}')/version('${{ steps.project-meta.outputs.next-version }}')/" \ | |
| src/cli.js; | |
| # Generate changelog | |
| # | |
| # NOTE: we use the 'latest' tag here, because starting from an rc/alpha/beta release | |
| # the rc/alpha/beta release tags are ignored and the "latest" tag is the previous stable version | |
| - name: Generate changelog | |
| working-directory: ${{ steps.project-meta.outputs.project-dir }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }} | |
| run: | | |
| export IS_PRERELEASE=$(node scripts/semver-is-prerelease.mjs ${{ steps.project-meta.outputs.next-version }}); | |
| export START_ARG="--latest"; | |
| if [ "true" == "$IS_PRERELEASE" ]; then | |
| export START_ARG="--unreleased"; | |
| fi | |
| git cliff \ | |
| --repository=${{ github.workspace }}/.git \ | |
| --config=./cliff.toml \ | |
| $START_ARG \ | |
| --tag=${{ steps.project-meta.outputs.next-version }} \ | |
| --prepend=CHANGELOG.md | |
| # Create release PR | |
| - name: Create release prep PR | |
| uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | |
| with: | |
| branch: prep-release-v${{ steps.project-meta.outputs.next-version }} | |
| token: ${{ secrets.RELEASE_PAT || secrets.GITHUB_TOKEN }} | |
| commit-message: | | |
| release: componentize-js v${{ steps.project-meta.outputs.next-version }} | |
| title: | | |
| release: componentize-js v${{ steps.project-meta.outputs.next-version }} | |
| labels: | | |
| release-pr | |
| assignees: >- | |
| vados-cosmonic, | |
| tschneidereit | |
| signoff: true | |
| body: | | |
| This is a release prep branch for `componentize-js` release `v${{ steps.project-meta.outputs.next-version }}`. | |
| To ensure this release is ready to be merged: | |
| - [ ] Review updated CHANGELOG(s) | |
| After this PR is merged tagging, artifact builds and releasing will run automatically. |