This repository has been archived on 2024-02-15. You can view files and clone it, but cannot push or open issues or pull requests.
config-mapper/release.sh

75 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
VERSION=v0.3.0
log() {
NTR=$'\033[0m' # * Neutral
INF=$'\033[0;34m' # * Blue (info)
WRN=$'\033[1;33m' # * Yellow (warning)
ERR=$'\033[1;31m' # * Red (error)
log_lvl=""
case $1 in
INFO)
log_lvl="${INF}$1"
;;
WARNING)
log_lvl="${WRN}$1"
;;
ERROR)
log_lvl="${ERR}$1"
;;
esac
log_lvl="${log_lvl}${NTR}"
msg="${log_lvl}\t$2"
echo -e "${msg}"
}
log "INFO" "checking required dependencies to create release"
if ! type git 1> /dev/null; then
log "ERROR" "\"git\" binary not available"
exit 1
fi
if ! type sd 1> /dev/null; then
log "ERROR" "\"sd\" binary not available"
exit 1
fi
if ! type gh 1> /dev/null; then
log "ERROR" "\"gh\" binary not available"
exit 1
fi
if ! type go 1> /dev/null; then
log "ERROR" "\"go\" binary not available"
exit 1
fi
if ! type git-chglog 1> /dev/null; then
log "ERROR" "\"git-chglog\" binary not available"
exit 1
fi
read -p "Enter a release version (vX.Y.Z): " release
log "INFO" "updating release version in files"
sd "Version: \"$VERSION\"" "Version: \"$release\"" cmd/cli.go
sd "VERSION=$VERSION" "VERSION=$release" release.sh
log "INFO" "updating changelog"
git-chglog --next-tag $release --output CHANGELOG.md
log "INFO" "commit & push changes"
git add .
git commit -m "$release"
git push
git tag -a $release -m $release
git push --tags
log "INFO" "building Linux binary"
GOOS=linux go build -o build/x86-x64_linux_config-mapper
log "INFO" "building Darwin binary"
GOOS=darwin go build -o build/x86-x64_darwin_config-mapper
log "INFO" "creating release"
gh release create $release -n $(git-chglog -t .chglog/RELEASE_CHANGELOG.tpl.md) build/x86-x64_*