Skip to content

Commit

Permalink
ci: add build and publish steps (#40)
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
bskim45 and coderabbitai[bot] authored Sep 16, 2024
1 parent 4b53dd9 commit df67ae7
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion .github/workflows/rubygems.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ jobs:
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']

steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
Expand Down Expand Up @@ -58,3 +59,48 @@ jobs:
if: matrix.ruby-version == '3.1'
env:
CC_TEST_REPORTER_ID: "${{ secrets.CC_TEST_REPORTER_ID }}"

build_and_publish:
name: Build and Publish
runs-on: ubuntu-latest

needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')

permissions:
contents: read
packages: write

env:
RUBY_VERSION: 2.7

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Ruby ${{ env.RUBY_VERSION }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true

- name: Publish to GPR
run: |
mkdir -p "$HOME/.gem"
touch "$HOME/.gem/credentials"
chmod 0600 "$HOME/.gem/credentials"
printf -- "---\n:github: %s\n" "${GEM_HOST_API_KEY}" > "$HOME/.gem/credentials"
gem build -- *.gemspec
gem push --KEY github --host "https://rubygems.pkg.github.com/${OWNER}" -- *.gem
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 }}

- name: Publish to RubyGems
uses: rubygems/release-gem@v1

0 comments on commit df67ae7

Please sign in to comment.