chore(dev): prepare to release individual packages #722
Workflow file for this run
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-n-Release | |
| # NOTE: The change log is only updated in the remote upon release (in `bump-release` job) | |
| on: | |
| push: | |
| branches: | |
| - "main" | |
| pull_request: | |
| branches: | |
| - "main" | |
| workflow_dispatch: | |
| inputs: | |
| package: | |
| description: The package to release | |
| type: choice | |
| required: true | |
| default: cpp-linter | |
| options: | |
| - cpp-linter | |
| - cpp-linter-js | |
| - cpp-linter-py | |
| - clang-installer | |
| component: | |
| description: The version component to increase | |
| type: choice | |
| required: true | |
| default: patch | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| - rc | |
| permissions: {} | |
| jobs: | |
| bump-release: | |
| if: github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| token: ${{ secrets.BUMP_N_RELEASE }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: true # needed for `git push` | |
| - name: Set up Python | |
| if: inputs.package == 'cpp-linter-py' | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Install Node.js | |
| if: inputs.package == 'cpp-linter-js' | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.x | |
| - run: yarn install | |
| if: inputs.package == 'cpp-linter-js' | |
| - uses: cargo-bins/cargo-binstall@f8ce4d55b131f4a1e373b8747ca6b6a54133ae5a # v1.18.0 | |
| - run: cargo binstall -y git-cliff | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Install nushell | |
| uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 | |
| - name: Bump ${{ inputs.component }} version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.BUMP_N_RELEASE }} | |
| GH_TOKEN: ${{ secrets.BUMP_N_RELEASE }} | |
| run: nu .github/workflows/bump-n-release.nu ${{ inputs.package }} ${{ inputs.component }} | |
| id: tagged | |
| get-changed-pkgs: | |
| if: github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/') | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pkgs: ${{ steps.set-pkgs.outputs.pkgs }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Install nushell | |
| uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 | |
| - name: Get changed packages | |
| id: set-pkgs | |
| shell: nu {0} | |
| run: |- | |
| cd ${{ github.workspace }} | |
| source ${{ github.workspace }}/.github/workflows/bump-n-release.nu | |
| let pkgs = get-changed-pkgs.nu | |
| "pkgs=($pkgs)\n" | save --append $env.GITHUB_OUTPUT | |
| update-changelog: | |
| if: github.event_name != 'workflow_dispatch' | |
| needs: get-changed-pkgs | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| pkg: ${{ fromJSON(needs.get-changed-pkgs.outputs.pkgs) }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| persist-credentials: false | |
| - uses: cargo-bins/cargo-binstall@f8ce4d55b131f4a1e373b8747ca6b6a54133ae5a # v1.18.0 | |
| - run: cargo binstall -y git-cliff | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| - name: Install nushell | |
| uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 | |
| - name: Generate a release notes | |
| env: | |
| PKG: ${{ matrix.pkg }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| GITHUB_REPO: ${{ github.repository }} | |
| GIT_CLIFF_CONFIG: .config/cliff.toml | |
| shell: nu {0} | |
| run: |- | |
| cd ${{ github.workspace }} | |
| source ${{ github.workspace }}.github/workflows/bump-n-release.nu | |
| gen-changes $env.PKG --unreleased | |
| let out = open --raw .config/ReleaseNotes.md | |
| $"## ($env.PKG)\n\n($out)" | save --append $env.GITHUB_STEP_SUMMARY |