Skip to content

Commit abca3e4

Browse files
author
Jonathan Thurman
committed
chore(build): Add release script
1 parent 11f8f03 commit abca3e4

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#############################
2+
# Global vars
3+
#############################
4+
PROJECT_NAME := $(shell basename $(shell pwd))
5+
PROJECT_VER ?= $(shell git describe --tags --always --dirty | sed -e '/^v/s/^v\(.*\)$$/\1/g')
6+
# Last released version (not dirty) without leading v
7+
PROJECT_VER_TAGGED := $(shell git describe --tags --always --abbrev=0 | sed -e '/^v/s/^v\(.*\)$$/\1/g')
8+
9+
SRCDIR ?= .
10+
RELEASE_SCRIPT ?= ./scripts/release.sh
11+
12+
all:
13+
@echo "=== $(PROJECT_NAME) === [ all ]: Supported targets:"
14+
@echo " release - Create new release"
15+
16+
17+
# Example usage: make release version=0.11.0
18+
release:
19+
@echo "=== $(PROJECT_NAME) === [ release ]: Generating release."
20+
$(RELEASE_SCRIPT) $(version)
21+
22+
23+
.PHONY: all build

scripts/release.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
COLOR_RED='\033[0;31m'
4+
COLOR_NONE='\033[0m'
5+
CURRENT_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
6+
7+
if [ $CURRENT_GIT_BRANCH != 'master' ]; then
8+
printf "\n"
9+
printf "${COLOR_RED} Error: The release.sh script must be run while on the master branch. \n ${COLOR_NONE}"
10+
printf "\n"
11+
12+
exit 1
13+
fi
14+
15+
if [ $# -ne 1 ]; then
16+
printf "\n"
17+
printf "${COLOR_RED} Error: Release version argument required. \n\n ${COLOR_NONE}"
18+
printf " Example: \n\n ./tools/release.sh 0.9.0 \n\n"
19+
printf " Example (make): \n\n make release version=0.9.0 \n"
20+
printf "\n"
21+
22+
exit 1
23+
fi
24+
25+
RELEASE_VERSION=$1
26+
GIT_USER=$(git config user.email)
27+
28+
echo "Generating release for v${RELEASE_VERSION} using system user git user ${GIT_USER}"
29+
30+
git checkout -b release/v${RELEASE_VERSION}
31+
32+
# Auto-generate CHANGELOG updates
33+
git-chglog --next-tag v${RELEASE_VERSION} -o CHANGELOG.md
34+
35+
# Commit CHANGELOG updates
36+
git add CHANGELOG.md
37+
git commit -m "chore(changelog): Update CHANGELOG for v${RELEASE_VERSION}"
38+
git push origin release/v${RELEASE_VERSION}

0 commit comments

Comments
 (0)