CI: Publish to RubyGems

This commit is contained in:
Claudio Bley 2022-03-19 22:39:11 +01:00
parent 61050314de
commit f9dd1b44ef
3 changed files with 28 additions and 5 deletions

View file

@ -37,3 +37,26 @@ jobs:
run: bundle exec rake
- name: Run checks
run: test/run
publish:
needs: test
runs-on: ubuntu-latest
if: success() && github.event_name == 'push'
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
bundle exec rake publish
env:
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_API_KEY }}"

View file

@ -20,7 +20,7 @@ file 'man/colorls.1' => ['man/colorls.1.ronn', 'lib/colorls/flags.rb'] do
flags = ColorLS::Flags.new
attributes = {
date: Date.iso8601(`git log -1 --pretty=format:%cI -- man/colorls.1`),
date: Date.iso8601(`git log -1 --pretty=format:%cI -- lib/colorls/flags.rb`),
manual: 'colorls Manual',
organization: "colorls #{ColorLS::VERSION}"
}

View file

@ -27,13 +27,13 @@ POST_INSTALL_MESSAGE = %(
# rubocop:disable Metrics/BlockLength
Gem::Specification.new do |spec|
is_tagged = ENV['TRAVIS_TAG'] == "v#{ColorLS::VERSION}"
is_origin = ENV['TRAVIS_REPO_SLUG'] == 'athityakumar/colorls'
build_number = ENV['TRAVIS_BUILD_NUMBER']
is_tagged = ENV['GITHUB_REF'] == "refs/tags/v#{ColorLS::VERSION}"
is_origin = ENV['GITHUB_REPOSITORY_OWNER'] == 'athityakumar'
build_number = ENV['GITHUB_RUN_NUMBER']
spec.name = 'colorls'
spec.version = if build_number && is_origin && !is_tagged
# Prereleasing on Travis CI
# Prereleasing on Github
digits = ColorLS::VERSION.to_s.split '.'
digits[-1] = digits[-1].to_s.succ