2021-08-18 08:03:31 +00:00
|
|
|
#!bin/bash
|
|
|
|
|
|
|
|
# get current branch
|
|
|
|
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
|
|
|
|
|
|
|
|
# push any local changes
|
|
|
|
git push
|
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# run a build to catch any uncommitted updates
|
|
|
|
npm run build
|
2021-08-18 08:03:31 +00:00
|
|
|
|
|
|
|
# branch validation
|
|
|
|
if [ $branch = "dev" ]; then
|
2021-08-22 06:55:10 +00:00
|
|
|
# check current branch is clean
|
|
|
|
if output=$(git status --porcelain) && [ -z "$output" ]; then
|
|
|
|
|
|
|
|
# get the version number
|
2021-08-22 07:29:18 +00:00
|
|
|
echo "Enter the release version (eg. 1.2.0):"
|
2021-08-22 06:55:10 +00:00
|
|
|
read version
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 07:29:18 +00:00
|
|
|
echo "Started releasing Congo v$version..."
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# update package version
|
|
|
|
jq --arg version "$version" '.version=$version' package.json > package.tmp && mv package.tmp package.json
|
2021-08-22 07:29:18 +00:00
|
|
|
sed -i "" -e "1s/^\(\/\*! Congo \)v[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}/\1v$version/" assets/css/main.css
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# update changelog
|
|
|
|
chan release $version || exit
|
|
|
|
npx prettier --write CHANGELOG.md
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# build project
|
|
|
|
npm run build
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# commit version updates
|
2021-08-22 07:29:18 +00:00
|
|
|
git commit -a -m "🔨 Preparing release v$version"
|
2021-08-22 06:55:10 +00:00
|
|
|
git push
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# switch to stable branch
|
|
|
|
git checkout stable
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# pull latest from stable
|
|
|
|
git pull
|
2021-08-18 08:03:31 +00:00
|
|
|
|
2021-08-22 06:55:10 +00:00
|
|
|
# merge in changes from dev branch
|
2021-08-22 07:29:18 +00:00
|
|
|
git merge --no-ff dev -m "🔖 Release v$version"
|
2021-08-22 06:55:10 +00:00
|
|
|
|
|
|
|
# create tag
|
2021-10-19 06:59:13 +00:00
|
|
|
git tag "v$version"
|
2021-08-22 06:55:10 +00:00
|
|
|
|
|
|
|
# push commit and tag to remote
|
|
|
|
git push
|
|
|
|
git push --tags
|
|
|
|
|
|
|
|
# publish GitHub release
|
|
|
|
timeout 2 chan gh-release $version
|
|
|
|
|
2021-08-22 07:29:18 +00:00
|
|
|
echo "Congo v$version successfully released! 🎉"
|
2021-08-22 06:55:10 +00:00
|
|
|
echo "Returning to dev branch..."
|
|
|
|
|
|
|
|
git checkout dev
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "ERROR: There are unstaged changes in development!"
|
|
|
|
echo "Clean the working directory and try again."
|
|
|
|
fi
|
2021-08-18 08:03:31 +00:00
|
|
|
else
|
2021-08-22 06:55:10 +00:00
|
|
|
echo "ERROR: Releases can only be published from the dev branch!"
|
2021-08-18 08:03:31 +00:00
|
|
|
fi
|