v1.0.3 #12
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" ] | |
| 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: Get Local Tag Name | |
| run: | | |
| TAG_NAME=$(ruby -I. -r lib/restful_error/version -e 'puts "v#{RestfulError::VERSION}"') | |
| echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
| - name: Check already released | |
| run: | | |
| if git tag | grep -q $TAG_NAME; then | |
| echo "$TAG_NAME already released. skip." | |
| exit 0 | |
| fi | |
| - 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: 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 |