Tag on Github and Release to RubyGems #5
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
--- | |
name: Tag on Github and Release to RubyGems | |
on: [workflow_dispatch] | |
jobs: | |
release: | |
name: Release to RubyGems | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 | |
- name: Tag on Github | |
run: | | |
VERSION=$(ruby -e "puts Gem::Specification::load('datatrans.gemspec').version") | |
echo "v$VERSION" | |
git tag "v$VERSION" | |
git push origin "v$VERSION" | |
- name: Publish to RubyGems | |
run: | | |
mkdir -p $HOME/.gem | |
touch $HOME/.gem/credentials | |
chmod 0600 $HOME/.gem/credentials | |
printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials | |
gem build *.gemspec | |
gem push *.gem | |
env: | |
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} |