Skip to content
This repository has been archived by the owner on Mar 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from suzuki-shunsuke/chore/add-release.sh
Browse files Browse the repository at this point in the history
chore: add release.sh
  • Loading branch information
suzuki-shunsuke committed Jan 1, 2021
2 parents 93066b2 + a6227bb commit 6c46d17
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
2 changes: 0 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
const (
name = "tfnotify"
description = "Notify the execution result of terraform command"

version = "unset"
)

type tfnotify struct {
Expand Down
52 changes: 52 additions & 0 deletions scripts/release.sh
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"
7 changes: 7 additions & 0 deletions version.go
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"

0 comments on commit 6c46d17

Please sign in to comment.