Skip to content

Commit

Permalink
trying different approach for gem release
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiobayona committed Feb 22, 2024
1 parent adfcdfa commit 5768eb8
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions .github/workflows/gem-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,24 @@ on:
branches: [ "main" ]
types:
- closed

jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
name: Build + Publish with Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby:
- '3.2.2'

permissions:
contents: read
packages: write
steps:
- run: |
echo The PR was merged
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
contents: write
id-token: write

- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}
environment: release

steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

- name: Publish to RubyGems
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 build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
# Release
- uses: rubygems/release-gem@v1

0 comments on commit 5768eb8

Please sign in to comment.