-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update push_build script to select which version part to bump
- Loading branch information
Showing
2 changed files
with
93 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
ROOT_DIR="$(dirname "$SCRIPT_DIR")" | ||
push_tag() { | ||
TAG=$1 | ||
git tag $TAG -m "$TAG" | ||
git push origin $TAG | ||
git tag -d $TAG | ||
CURRENT_BRANCH=$(git symbolic-ref --short HEAD) | ||
COMMIT=$(git log -n 1 --pretty=format:"%h") | ||
echo "Pushed tag '$TAG' to branch '$CURRENT_BRANCH' at commit '$COMMIT'." | ||
} | ||
|
||
LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1)` | ||
PARTS=(${LAST_TAG//-/ }) | ||
NEW_VERSION=$(cat "$ROOT_DIR/Zotero.xcodeproj/project.pbxproj" | grep MARKETING_VERSION | head -n 1 | sed -E 's/.+([0-9]+\.[0-9]+\.[0-9]+).+/\1/') | ||
NEW_BUILD=$((${PARTS[1]}+1)) | ||
DEFAULT_TAG="trigger-build-bump-patch" | ||
|
||
TAG="$NEW_VERSION-$NEW_BUILD" | ||
if [ $# -eq 0 ]; then | ||
TAG=$DEFAULT_TAG | ||
else | ||
case $1 in | ||
"minor"|"major"|"patch") | ||
TAG="trigger-build-bump-$1" | ||
;; | ||
*) | ||
echo "Invalid tag argument. Usage: $0 [patch (default)|minor|major]" | ||
exit 1 | ||
;; | ||
esac | ||
fi | ||
|
||
echo "Pushing tag: $TAG" | ||
git tag -a ${TAG} -m "$TAG" | ||
git push origin ${TAG} | ||
if [ "$TAG" != "$DEFAULT_TAG" ]; then | ||
read -p "Are you sure you want to push tag '$TAG'? (y/n): " choice | ||
if [ "$choice" != "y" ]; then | ||
echo "Operation canceled." | ||
exit 0 | ||
fi | ||
fi | ||
|
||
push_tag $TAG |