-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a github action to publish gem to Rubygem
- Loading branch information
1 parent
c3222f9
commit 457c835
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Push to RubyGems | ||
|
||
on: workflow_dispatch | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
ruby-version: ["3.3", "3.2", "3.1", "3.0"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby ${{ matrix.ruby-version }} | ||
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108 | ||
with: | ||
ruby-version: ${{ matrix.ruby-version }} | ||
- name: Install dependencies | ||
run: bundle install | ||
- name: Run tests | ||
run: bundle exec rspec | ||
|
||
publish: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108 | ||
with: | ||
ruby-version: "3.1" | ||
|
||
- 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}}" |