Release Gem #2
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 Gem | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag_name: | |
| description: 'The tag to create (e.g. v0.3.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| release: | |
| name: Build and Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # allowed to push tags and create releases | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: 3.3 # pinned to 3.3 to support unicode-emoji < 4.0 requirement | |
| bundler-cache: true | |
| - name: Run tests | |
| run: bundle exec rake | |
| - name: Create and Push Tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag ${{ inputs.tag_name }} | |
| git push origin ${{ inputs.tag_name }} | |
| - name: Build Gem | |
| run: | | |
| gem build *.gemspec | |
| - name: Publish to RubyGems | |
| env: | |
| GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| run: | | |
| mkdir -p $HOME/.gem | |
| touch $HOME/.gem/credentials | |
| chmod 0600 $HOME/.gem/credentials | |
| printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | |
| gem push *.gem | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ inputs.tag_name }} | |
| generate_release_notes: true |