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

chore: add release.sh #4

Merged
merged 1 commit into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"