Merge pull request #307 from github/mgriffin/bump #5
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: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- lib/version.rb | |
permissions: | |
contents: write | |
packages: write | |
id-token: write | |
attestations: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@13e7a03dc3ac6c3798f4570bfead2aed4d96abfb # pin@v1.244.0 | |
with: | |
bundler-cache: true | |
- name: lint | |
run: script/lint | |
- name: test | |
run: script/test | |
- name: set GEM_NAME from gemspec | |
run: echo "GEM_NAME=$(ls | grep gemspec | cut -d. -f1)" >> $GITHUB_ENV | |
# builds the gem and saves the version to GITHUB_ENV | |
- name: build | |
run: echo "GEM_VERSION=$(gem build ${{ env.GEM_NAME }}.gemspec 2>&1 | grep Version | cut -d':' -f 2 | tr -d " \t\n\r")" >> $GITHUB_ENV | |
- uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # pin@v2 | |
with: | |
subject-path: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem" | |
- name: publish to GitHub packages | |
run: | | |
export OWNER=$( echo ${{ github.repository }} | cut -d "/" -f 1 ) | |
GEM_HOST_API_KEY=${{ secrets.GITHUB_TOKEN }} gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem | |
- name: release | |
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # pin@v1.16.0 | |
with: | |
artifacts: "${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem" | |
tag: "v${{ env.GEM_VERSION }}" | |
generateReleaseNotes: true | |
- name: publish to RubyGems | |
run: | | |
mkdir -p ~/.gem | |
echo -e "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials | |
chmod 0600 ~/.gem/credentials | |
gem push ${{ env.GEM_NAME }}-${{ env.GEM_VERSION }}.gem | |
rm ~/.gem/credentials |