Skip to content

Commit

Permalink
Added GITHUB_TOKEN env var check and user confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZerGo0 committed Sep 25, 2024
1 parent 8514ba3 commit ebf3466
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/usr/bin/env bash

# make sure that the GITHUB_TOKEN env var is set
if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set"
exit 1
fi

# make sure that the repo is clean
DIRTY=$(git status --porcelain)
if [ ! -z "$DIRTY" ]; then
Expand All @@ -9,14 +15,14 @@ fi

git pull origin master

# get the latest tag
LATEST_TAG=$(git describe --abbrev=0 --tags)

# increment the minor version
NEXT_VERSION=$(echo $LATEST_TAG | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')

echo "New version: $NEXT_VERSION"

# ask user for confirmation
read -p "Are you sure? " -n 1 -r

git tag -a "$NEXT_VERSION" -m "Version $NEXT_VERSION"
git push origin "$NEXT_VERSION"

Expand Down

0 comments on commit ebf3466

Please sign in to comment.