This repository has been archived by the owner on Mar 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from suzuki-shunsuke/chore/add-release.sh
chore: add release.sh
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env bash | ||
# Usage | ||
# bash scripts/tag.sh v1.0.0 | ||
|
||
set -eu | ||
set -o pipefail | ||
|
||
REMOTE=https://github.com/suzuki-shunsuke/tfnotify | ||
|
||
ee() { | ||
echo "+ $*" | ||
eval "$@" | ||
} | ||
|
||
BRANCH="$(git branch | grep "^\* " | sed -e "s/^\* \(.*\)/\1/")" | ||
if [ "$BRANCH" != "master" ]; then | ||
read -r -p "The current branch isn't master but $BRANCH. Are you ok? (y/n)" YN | ||
if [ "${YN}" != "y" ]; then | ||
echo "cancel to release" | ||
exit 0 | ||
fi | ||
fi | ||
|
||
TAG="$1" | ||
echo "TAG: $TAG" | ||
VERSION="${TAG#v}" | ||
|
||
if [ "$TAG" = "$VERSION" ]; then | ||
echo "the tag must start with 'v'" >&2 | ||
exit 1 | ||
fi | ||
|
||
ee cd "$(dirname "$0")/.." | ||
|
||
VERSION_FILE=version.go | ||
echo "create $VERSION_FILE" | ||
cat << EOS > "$VERSION_FILE" | ||
package constant | ||
// Don't edit this file. | ||
// This file is generated by the release command. | ||
// Version is the tfnotify's version. | ||
const version = "$VERSION" | ||
EOS | ||
|
||
ee git add "$VERSION_FILE" | ||
echo "+ git commit -m \"build: update version to $TAG\"" | ||
git commit -m "build: update version to $TAG" | ||
ee git tag "$TAG" | ||
ee git push "$REMOTE" "$BRANCH" | ||
ee git push "$REMOTE" "$TAG" |
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,7 @@ | ||
package main | ||
|
||
// Don't edit this file. | ||
// This file is generated by the release command. | ||
|
||
// version is the tfnotify's version. | ||
const version = "1.0.0-0" |