diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cac7e2..5b91091 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,6 @@ on: push: tags: - 'v*' - workflow_dispatch: - inputs: - tag: - description: 'Which Git tag to release (e.g. vO.1.O)' jobs: homebrew: @@ -24,8 +20,19 @@ jobs: # Formula name, required formula: manymessage # Optional, will be determined automatically - tag: ${{github.ref || github.event.inputs.tags}} + tag: ${{github.ref}} # Optional, will be determined automatically revision: ${{github.sha}} # Optional, if don't want to check for already open PRs force: false + rubygems: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Release Gem + if: contains(github.ref, 'refs/tags/v') + uses: cadwallion/publish-rubygems-action@master + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} + RELEASE_COMMAND: "rake workflow:release:gem" diff --git a/Gemfile.lock b/Gemfile.lock index 47d3b89..df8a4e5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - manymessage (0.1.1) + manymessage (0.1.2) imessage (~> 0.4.0) json (~> 2.6) os (~> 1.1) diff --git a/Rakefile b/Rakefile index df40677..a4430a1 100644 --- a/Rakefile +++ b/Rakefile @@ -8,3 +8,38 @@ RSpec::Core::RakeTask.new(:spec) require "standard/rake" task default: %i[spec standard] + +# Adds renaming of Rake tasks, from https://blog.ladslezak.cz/2009/06/03/renaming-rake-task/ +module Rake + class Application + def rename_task(task, oldname, newname) + @tasks = {} if @tasks.nil? + @tasks[newname.to_s] = task + + @tasks.delete(oldname) if @tasks.has_key?(oldname) + end + end +end + +# add new rename method to Rake::Task class +# to rename a task +class Rake::Task + def rename(new_name) + if !new_name.nil? + old_name = @name + + return if old_name == new_name + + @name = new_name.to_s + application.rename_task(self, old_name, new_name) + end + end +end + +Rake::Task[:release].rename(:"release:gem") + +desc "Release to RubyGems, but don't create a version tag (for use in release GitHub Action workflow)" +task :"workflow:release:gem" do + `gem install gem-release` + `gem release` +end diff --git a/lib/manymessage/version.rb b/lib/manymessage/version.rb index ad3fe90..9b77249 100644 --- a/lib/manymessage/version.rb +++ b/lib/manymessage/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Manymessage - VERSION = "0.1.1" + VERSION = "0.1.2" end