Skip to content

Commit

Permalink
Improved release script
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmarechal committed Dec 28, 2022
1 parent a654c17 commit 294f6b2
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,14 @@ _cmd_list_versions(){
}

_cmd_show_last_version(){
echo "Latest version: "
fetch_last_versions 1
echo "Latest version: $(fetch_last_versions 1)"
}

_cmd_create_version(){
if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then
VERSION="${VERSION^^}" # ^^ => String to upper
fi

current_branch=$(git rev-parse --abbrev-ref HEAD)

handle_version_value
Expand All @@ -176,7 +179,6 @@ _cmd_create_version(){

remote=$(git remote | head -1)

echo "Version $VERSION will be created."
echo ""
echo "Updating local repository..."
echoeval git pull
Expand All @@ -200,15 +202,22 @@ _cmd_create_version(){
archive_name=$(get_archive_name)
zipfile="$archive_name.zip"
targzfile="$archive_name.tar.gz"
test -f "$zipfile" && echoeval rm "$zipfile"
test -f "$targzfile" && echoeval rm "$targzfile"
echo "Creating archives $zipfile and $targzfile..."
echoeval zip $archive_name.zip $INCLUDED_FILES
echoeval tar -czf $archive_name.tar.gz $INCLUDED_FILES
echo ""

echo "returning back to previous branch $current_branch..."
git checkout $current_branch

echo ""

remote_url=$(git remote get-url origin)
release_url="$remote_url/releases/new?tag=$tag"
echo "Publish your new release: $release_url"
echo ""

echo "DONE!"
}

Expand All @@ -230,7 +239,7 @@ while [[ $# -gt 0 ]]; do
;;
create)
CMD_CREATE_VERSION=1
VERSION="${2^^}" # ^^ => String to upper
VERSION=$2
shift
;;
-*|--*)
Expand All @@ -241,6 +250,10 @@ while [[ $# -gt 0 ]]; do
shift
done

# Move to project folder
current_dir=$PWD
test "$ROOT" != "." && echoeval cd $ROOT

if [[ $CMD_LATEST_VERSION == 1 ]]; then
_cmd_show_last_version
elif [[ $CMD_LIST_VERSIONS == 1 ]]; then
Expand Down

0 comments on commit 294f6b2

Please sign in to comment.