Release on tag update #7
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: Tag Release | |
| env: | |
| GEM_NAME: query_packwerk | |
| GEM_CLASS_NAME: QueryPackwerk | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| actions: read | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.2 | |
| - name: Determine release type | |
| id: version | |
| run: | | |
| if [[ "${{ github.event.pull_request.labels[*] }}" == *"major"* ]]; then | |
| echo "bump=major" >> $GITHUB_OUTPUT | |
| elif [[ "${{ github.event.pull_request.labels[*] }}" == *"minor"* ]]; then | |
| echo "bump=minor" >> $GITHUB_OUTPUT | |
| else | |
| echo "bump=patch" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Bump version | |
| run: | | |
| gem install bump | |
| bump ${{ steps.version.outputs.bump }} | |
| - name: Commit and tag version bump | |
| run: | | |
| # Attribute commits to the last committer on HEAD | |
| git config --global user.email "$(git log -1 --pretty=format:'%ae')" | |
| git config --global user.name "$(git log -1 --pretty=format:'%an')" | |
| git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY" | |
| VERSION=$(ruby -e "require './lib/${{ env.GEM_NAME }}/version'; puts ${{ env.GEM_CLASS_NAME }}::VERSION") | |
| git commit -am "Bump version to $VERSION" | |
| git tag "v$VERSION" | |
| git push origin main "v$VERSION" |