-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adding semantic-release for doing manual release
fixes #51
- Loading branch information
1 parent
a09c667
commit 559eb3c
Showing
3 changed files
with
26 additions
and
43 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,8 @@ | ||
{ | ||
"branches": ["master"], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github" | ||
] | ||
} |
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,39 +1,13 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Script to release a new Terraform Module version. | ||
# The script expects the version to release in the format v<major>.<minor>.<patch>. | ||
# It then creates and pushes the tag and prints out the changelog. | ||
|
||
set -e | ||
|
||
# check version is passed and sanity check semantic format | ||
if [ $# -ne 1 ]; then | ||
echo "Usage: $0 <release-version>" >&2 | ||
if [ -z "$GH_TOKEN" ] | ||
then | ||
echo "A valif GitHub token must be set via the environment variable GH_TOKEN" | ||
exit 1 | ||
fi | ||
|
||
version=$1 | ||
echo $version | grep -q 'v[0-9]\+\.[0-9]\+\.[0-9]\+' || (echo "Specified release version '$version' is not semantic" >&2; exit 1) | ||
|
||
# make sure we are on master and have no uncommited changes | ||
branch=$(git rev-parse --abbrev-ref HEAD) | ||
if [ "$branch" != "master" ]; then | ||
echo "You need to be on master to release" >&2 | ||
exit 1 | ||
fi | ||
|
||
git diff-index --quiet HEAD -- || (echo "There are uncommited changes on branch '$branch'" >&2; exit 1) | ||
|
||
# create and push tag; this will create GitHub release | ||
git tag -a $version -m "release $version" | ||
git push --follow-tags | ||
|
||
# create changelog by determining the commits between the last to tags | ||
# use 'git merge-base' in case the tags occured on a detached head | ||
prev_tag=$(git for-each-ref --sort=-creatordate --format="%(objectname)" refs/tags | sed -n 2p) | ||
prev_tag_base=$(git merge-base $prev_tag master) | ||
current_tag=$(git for-each-ref --sort=-creatordate --format="%(objectname)" refs/tags | sed -n 1p) | ||
current_tag_base=$(git merge-base $current_tag master) | ||
|
||
# actual changelog creation | ||
jx step changelog -v $version -p $prev_tag_base -r $current_tag_base --generate-yaml=false --no-dev-release --update-release=false | ||
docker run -w /app --rm -v $(pwd):/app -e GH_TOKEN=$GH_TOKEN gtramontina/semantic-release:17.0.2 -r https://github.com/jenkins-x/terraform-google-jx --no-ci |