git-bot-feedback 0.7.0

A library designed for CI tools that posts comments on a Pull Request.
Documentation
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
        options:
          - git-bot-feedback
          - git-bot-feedback-py
      component:
        description: The version component to increase
        type: choice
        required: true
        default: patch
        options:
          - major
          - minor
          - patch

permissions: {}

jobs:
  bump-release:
    if: github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    environment: stage-deployment
    steps:
      - name: Checkout repository
        uses: actions/checkout@v7
        with:
          token: ${{ secrets.BUMP_N_RELEASE }}
          fetch-depth: 0
          fetch-tags: true
          persist-credentials: true # needed for `git push`
      - uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65 # v1.20.1
      - run: cargo binstall -y git-cliff
        env:
          GITHUB_TOKEN: ${{ github.token }}
      - name: Install nushell
        uses: hustcer/setup-nu@ccd5bb5426b05a32009c2ba967946231f3919c97 # v3.25
        with:
          version: ${{ vars.NUSHELL_VERSION || '*' }}
      - name: Install cargo-edit
        run: >-
          cargo install cargo-edit
          --no-default-features
          --features set-version
          --locked
      - 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 }}

  get-changed-pkgs:
    if: github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    outputs:
      pkgs: ${{ steps.get-pkgs.outputs.pkgs }}
    steps:
      - uses: actions/checkout@v7
        with:
          fetch-depth: 0
          persist-credentials: false
      - name: Install nushell
        uses: hustcer/setup-nu@ccd5bb5426b05a32009c2ba967946231f3919c97 # v3.25
        with:
          version: ${{ vars.NUSHELL_VERSION || '*' }}
      - name: Get changed packages
        id: get-pkgs
        env:
          HEAD_REF: ${{ github.event.pull_request.head.sha || 'HEAD' }}
          BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD~1'}}
        shell: nu {0}
        run: |-
          print (pwd)
          use ("./.github/workflows/bump-n-release.nu" | path expand) get-changed-pkgs
          let pkgs = (get-changed-pkgs)
          $"pkgs=($pkgs)\n" | save --append $env.GITHUB_OUTPUT

  update-changelog:
    if: github.event_name != 'workflow_dispatch' && needs.get-changed-pkgs.outputs.pkgs != '[]'
    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@v7
        with:
          fetch-depth: 0
          fetch-tags: true
          persist-credentials: false
      - uses: cargo-bins/cargo-binstall@732870f031d2fb36309d0deaf36abcc704a7be65 # v1.20.1
      - run: cargo binstall -y git-cliff
        env:
          GITHUB_TOKEN: ${{ github.token }}
      - name: Install nushell
        uses: hustcer/setup-nu@ccd5bb5426b05a32009c2ba967946231f3919c97 # v3.25
        with:
          version: ${{ vars.NUSHELL_VERSION || '*' }}
      - 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: |-
          use ("./.github/workflows/bump-n-release.nu" | path expand) gen-changes
          gen-changes $env.PKG --unreleased
          let out = open --raw .config/ReleaseNotes.md
          $"## ($env.PKG)\n\n($out)" | save --append $env.GITHUB_STEP_SUMMARY