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

Conversation

arharovets
Copy link
Contributor

No description provided.

@arharovets arharovets force-pushed the experiment_rubygems branch 2 times, most recently from db30494 to 563a0b4 Compare July 25, 2022 12:54
@arharovets arharovets changed the title experiment Use rubygems.org API to determine if the version should be bumped Jul 25, 2022
@arharovets arharovets force-pushed the experiment_rubygems branch from 30e22db to b934a60 Compare July 27, 2022 14:33
Comment on lines +17 to +19
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
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants