Add tag and create a new release on deploy action #8
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: Ruby Gem | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| jobs: | |
| test: | |
| uses: ./.github/workflows/test.yml | |
| build: | |
| needs: test | |
| name: Build + Publish | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby 3.3 | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.3 | |
| - name: build | |
| run: gem build *.gemspec | |
| - name: Publish to RubyGems | |
| run: gem push *.gem | |
| env: | |
| GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }} | |
| - name: Publish to GPR | |
| run: gem push --host https://rubygems.pkg.github.com/${OWNER} *.gem | |
| env: | |
| OWNER: ${{ github.repository_owner }} | |
| GEM_HOST_API_KEY: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Tag Name | |
| run: | | |
| TAG_NAME=$(ruby -e 'require_relative "lib/restful_error/version"; puts "v#{RestfulError::VERSION}"') | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| - name: Create Tag | |
| run: | | |
| git tag $TAG_NAME | |
| git push origin $TAG_NAME | |
| - name: Create Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| release_name: Release ${{ env.TAG_NAME }} | |
| draft: false | |
| prerelease: false |