Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rubygems.org API to determine if the version should be bumped #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/workflows/build-gem.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/gem-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check if the gem version exists on rubygems.org

on: [pull_request]

jobs:
build-gem:
runs-on: ubuntu-latest
continue-on-error: true
defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v2
- name: Compare local and remote gem versions
run: |
LOCAL_GEM_VERSION=$(cat lib/scc/codestyle/version.rb | grep VERSION | awk -F"'" '{print $2}')
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 "All good!" && echo exit 0); else (echo "Bump the gem version!" && exit 1); fi
Comment on lines +17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small big suggestion

Suggested change
LOCAL_GEM_VERSION=$(cat lib/scc/codestyle/version.rb | grep VERSION | awk -F"'" '{print $2}')
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 "All good!" && echo exit 0); else (echo "Bump the gem version!" && exit 1); fi
LOCAL_GEM_VERSION=$(ruby -I lib -e "require 'scc/codestyle'; print Scc::Codestyle::VERSION")
REMOTE_GEM_VERSION=$(curl 'https://rubygems.org/api/v1/versions/scc-codestyle/latest.json' | jq -r '.version')
LATEST_VERSION=$(printf '%s\n' "$LOCAL_GEM_VERSION" "$REMOTE_GEM_VERSION" | sort -rV | head -n 1)
if [ "$LATEST_VERSION" == "$REMOTE_GEM_VERSION" ]; then
echo "Bump the gem version!"
exit 1
fi

using ruby to get the version also does syntax check as a bonus hehe, also less text processing and you can use full bash syntax (with spaces & indents) since the block is defined with | .

e.g.: run: |

Besides that: I liked the latest version detection, pretty neat!

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.3'.freeze
end
end