diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 9f3af6b..96c5608 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -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 }}" diff --git a/Rakefile b/Rakefile index 159e162..6bd6886 100644 --- a/Rakefile +++ b/Rakefile @@ -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}" } diff --git a/colorls.gemspec b/colorls.gemspec index ee6dbbe..aef1c93 100644 --- a/colorls.gemspec +++ b/colorls.gemspec @@ -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