Skip to content

Instantly share code, notes, and snippets.

@hiiamyes
Created May 17, 2019 04:27
Show Gist options
  • Save hiiamyes/e1986049a1e43f229161b56c23f551c5 to your computer and use it in GitHub Desktop.
Save hiiamyes/e1986049a1e43f229161b56c23f551c5 to your computer and use it in GitHub Desktop.
get build number
# brew install jq
#!/bin/sh
commit_sha=$(curl -s "https://api.github.com/repos/hiiamyes/repo/branches/develop" \
-H 'Authorization: token {token}' |
jq -r '.commit.sha')
tag_name=$(curl -s "https://api.github.com/repos/hiiamyes/repo/tags" \
-H 'Authorization: token {token}' |
jq -r --arg commit_sha $commit_sha '.[] | select(.commit.sha == $commit_sha) | .name')
build_number=${tag_name/build-/}
build_number=${build_number/.1/}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment