Generalize release workflow to accommodate major or patch releases #13
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: release | |
| on: | |
| pull_request_target: | |
| types: [closed] | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| if: > | |
| github.event.pull_request.merged == true && | |
| contains(github.event.pull_request.labels.*.name, 'release') | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout the merged code | |
| - name: Checkout merged code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| fetch-depth: 0 | |
| # 2. Setup environment | |
| - name: Install Pixi | |
| uses: prefix-dev/setup-pixi@v0.8.9 | |
| - name: Fetch bot identity | |
| id: bot | |
| uses: raven-actions/bot-details@v1 | |
| - name: Configure git for committing | |
| run: | | |
| git config user.name "${{ steps.bot.outputs.name }}" | |
| git config user.email "${{ steps.bot.outputs.email }}" | |
| # 3. Bump version + read version | |
| - name: Bump version (patch) | |
| if: contains(github.event.pull_request.labels.*.name, 'release:patch') | |
| run: pixi run bumpver update --patch | |
| - name: Bump version (major) | |
| if: contains(github.event.pull_request.labels.*.name, 'release:major') | |
| run: pixi run bumpver update --major | |
| - name: Get version | |
| id: version | |
| run: | | |
| echo "tag=$(pixi run current-version)" >> "$GITHUB_OUTPUT" | |
| # 4. Create release | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.tag }} |