Skip to content

Commit

Permalink
Use rubygems.org API to determine if the version should be bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
arharovets committed Jul 25, 2022
1 parent 2d7be17 commit 563a0b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build-gem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ jobs:
build-gem:
runs-on: ubuntu-latest
continue-on-error: true
defaults:
run:
shell: bash

strategy:
matrix:
ruby-version: ['2.5', '2.7']

steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby-version }}
Expand All @@ -19,8 +22,6 @@ jobs:
ruby-version: ${{ matrix.ruby-version }}
- name: Check if gem exists
run: |
GEM_VERSION=$(ruby -e "require 'scc/codestyle'; print Scc::Codestyle::VERSION" -I lib)
# if we install the gem, then the $GEM_VERSION already exist on rubygems.org
# therefore error
gem install -q --silent scc-codestyle -v $GEM_VERSION && (touch failed-install && exit 0) || exit 0
test -f failed-install && (echo "bump the gem version!" && exit 1)
LOCAL_GEM_VERSION=$(ruby -e "require 'scc/codestyle'; print Scc::Codestyle::VERSION" -I lib)
REMOTE_GEM_VERSION=$(curl 'https://rubygems.org/api/v1/versions/scc-codestyle/latest.json' | jq '.version' | tr -d \")
if [ "$(printf '%s\n' "$LOCAL_GEM_VERSION" "$REMOTE_GEM_VERSION" | sort -rV | head -n 1)" != "$REMOTE_GEM_VERSION" ]; then echo exit 0; else (echo "bump the gem version!" && exit 1); fi
2 changes: 1 addition & 1 deletion lib/scc/codestyle/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Scc
module Codestyle
VERSION = '0.6.2'.freeze
VERSION = '0.6.4'.freeze
end
end

0 comments on commit 563a0b4

Please sign in to comment.