From d6d1775d793bcaf206af700120b0b4bd2dc3842d Mon Sep 17 00:00:00 2001 From: Nazar Matus Date: Tue, 19 Jan 2021 15:47:38 +0200 Subject: [PATCH 1/6] Fix Ruby 2.5 incopatibility We don't really need that second optional argument, as its default value is just what we need https://ruby-doc.org/core-2.7.2/Module.html#method-i-private_method_defined-3F --- lib/ruby2_keywords.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ruby2_keywords.rb b/lib/ruby2_keywords.rb index 97cd081..7a3f2fa 100644 --- a/lib/ruby2_keywords.rb +++ b/lib/ruby2_keywords.rb @@ -1,5 +1,5 @@ class Module - unless private_method_defined?(:ruby2_keywords, true) + unless private_method_defined?(:ruby2_keywords) private # call-seq: # ruby2_keywords(method_name, ...) From 956156ba793330928280c5301b093300a1a9f792 Mon Sep 17 00:00:00 2001 From: Nazar Matus Date: Tue, 19 Jan 2021 16:07:37 +0200 Subject: [PATCH 2/6] Add Ruby 2.5 to the CI matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b79ea7d..abe6e88 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,7 +7,7 @@ jobs: name: build (${{ matrix.ruby }} / ${{ matrix.os }}) strategy: matrix: - ruby: [ '3.0', 2.7, 2.6, head ] + ruby: [ '3.0', 2.7, 2.6, 2.5, head ] os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} steps: From 403ff84d12c9fe1f34397b3a164b0b2f73a560d1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 19 Jan 2021 23:25:17 +0900 Subject: [PATCH 3/6] Set SOURCE_DATE_EPOCH to make builds reproducible --- Rakefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Rakefile b/Rakefile index 8830e05..bfcf912 100644 --- a/Rakefile +++ b/Rakefile @@ -6,3 +6,9 @@ Rake::TestTask.new(:test) do |t| end task :default => :test + +task "build" => "date_epoch" + +task "date_epoch" do + ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp +end From fba8eb45d6b2db2d0f829b0d20300e7d19268146 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 19 Jan 2021 23:29:46 +0900 Subject: [PATCH 4/6] Build package --- .github/workflows/test.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index abe6e88..c5c461c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: ubuntu +name: test on: [push, pull_request] @@ -11,6 +11,11 @@ jobs: os: [ ubuntu-latest, macos-latest, windows-latest ] runs-on: ${{ matrix.os }} steps: + - name: git config + run: | + git config --global core.autocrlf false + git config --global core.eol lf + git config --global advice.detachedHead 0 - uses: actions/checkout@master - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -18,3 +23,17 @@ jobs: ruby-version: ${{ matrix.ruby }} - name: Run test run: rake test + - id: build + run: | + rake build + echo "::set-output name=pkg::${GITHUB_REPOSITORY#*/}-${RUNNING_OS%-*}" + env: + RUNNING_OS: ${{matrix.os}} + if: "matrix.ruby == '3.0'" + shell: bash + - name: Upload package + uses: actions/upload-artifact@v2 + with: + path: pkg/*.gem + name: ${{steps.build.outputs.pkg}} + if: steps.build.outputs.pkg From 8bf4b5b4169545ef5be46dec8cd6502d902a3e4a Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 19 Jan 2021 23:49:51 +0900 Subject: [PATCH 5/6] Added bump target --- Rakefile | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Rakefile b/Rakefile index bfcf912..6eb5091 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,8 @@ require "bundler/gem_tasks" require "rake/testtask" +helper = Bundler::GemHelper.instance + Rake::TestTask.new(:test) do |t| t.test_files = FileList["test/**/test_*.rb"] end @@ -12,3 +14,41 @@ task "build" => "date_epoch" task "date_epoch" do ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp end + +def helper.update_gemspec + path = "#{__dir__}/#{gemspec.name}.gemspec" + File.open(path, "r+b") do |f| + if (d = f.read).sub!(/^(version\s*=\s*)".*"/) {$1 + gemspec.version.to_s.dump} + f.rewind + f.truncate(0) + f.print(d) + end + end +end + +def helper.commit_bump + sh(%W[git -C #{__dir__} commit -m bump\ up\ to\ #{gemspec.version} + #{gemspec.name}.gemspec]) +end + +def helper.version=(v) + gemspec.version = v + update_gemspec + commit_bump + tag_version +end +major, minor, teeny = helper.gemspec.version.segments + +task "bump:teeny" do + helper.version = Gem::Version.new("#{major}.#{minor}.#{teeny+1}") +end + +task "bump:minor" do + raise "can't bump up minor" +end + +task "bump:major" do + raise "can't bump up major" +end + +task "bump" => "bump:teeny" From 31766f4327e6e4555543b44fc6a5dc252c8ff6d9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 19 Jan 2021 23:49:55 +0900 Subject: [PATCH 6/6] bump up to 0.0.4 --- ruby2_keywords.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby2_keywords.gemspec b/ruby2_keywords.gemspec index 5eac57b..8247998 100644 --- a/ruby2_keywords.gemspec +++ b/ruby2_keywords.gemspec @@ -1,4 +1,4 @@ -version = "0.0.3" +version = "0.0.4" abort "Version must not reach 1" if version[/\d+/].to_i >= 1 Gem::Specification.new do |s|