Skip to content

Commit

Permalink
CI: publish gem action.
Browse files Browse the repository at this point in the history
  • Loading branch information
ami-descope committed Mar 19, 2024
1 parent cc604d4 commit 345e7dc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,3 @@ jobs:
id: release
if: github.ref == 'refs/heads/main'

- 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_API_KEY}}"
if: ${{ steps.release.outputs.release_created }}
37 changes: 37 additions & 0 deletions .github/workflows/publish-gem.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish Ruby Gem

on:
release:
types: [created]

permissions:
contents: read
pull-requests: read # to detect changes files

jobs:
publish-gem:
name: Publish Ruby Gem
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
# We are not letting this step to run bundle install, we will do it later
bundler-cache: false

- name: Install dependencies
run: bundle install

- 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_API_KEY}}"
if: ${{ steps.release.outputs.release_created }}

0 comments on commit 345e7dc

Please sign in to comment.