-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Update version and tag for release. | ||
# Usage: ./release.sh <new_version> | ||
|
||
set -euxo pipefail | ||
|
||
if [[ $# -lt 1 ]]; then | ||
echo "Usage: $0 <new_version>" | ||
exit 1 | ||
fi | ||
|
||
PREV_VERSION=$(git describe --abbrev=0 --tags) | ||
NEW_VERSION=$1 | ||
|
||
read -p "Does update version from $PREV_VERSION to $NEW_VERSION? (y/n) :" YN | ||
|
||
if [[ "$YN" != "y" ]]; then | ||
echo "Aborted." | ||
exit 1 | ||
fi | ||
|
||
NOW_BRANCH=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
if [[ "$NOW_BRANCH" != "main" ]]; then | ||
echo "You must be on main branch." | ||
git checkout main | ||
fi | ||
|
||
echo "Merge develop branch to main branch." | ||
git merge develop | ||
|
||
echo "Rewrite files." | ||
sed -i "s/version=\"$PREV_VERSION\"/version=\"$NEW_VERSION\"/g" Dockerfile | ||
sed -i "s/zuke:$PREV_VERSION/zuke:$NEW_VERSION/g" compose.yml | ||
sed -i "s/\"version\": \"$PREV_VERSION\"/\"version\": \"$NEW_VERSION\"/g" package.json | ||
|
||
echo "Commit and push." | ||
git add Dockerfile compose.yml package.json | ||
git commit -m "Update version to $NEW_VERSION" | ||
git push origin main | ||
|
||
echo "Tag and push." | ||
git tag $NEW_VERSION | ||
git push origin $NEW_VERSION | ||
|
||
echo "Merge main branch to develop branch." | ||
git checkout develop | ||
git merge main | ||
git push origin develop | ||
|
||
echo "Done." | ||
|
||
echo "Summary of changes." | ||
git log --oneline --pretty=tformat:"%h %s" "$PREV_VERSION..$NEW_VERSION" | ||
|
||
exit 0 |