dnote/scripts/release.sh
Sung Won Cho f519793273
Write a smoke test for self-hosting (#310)
* Fix release script

* Write a smoke testing for self-hosting

* Allow to supply tarball path

* Clear db
2019-11-12 18:22:20 +08:00

58 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# release.sh releases the tarballs and checksum in the build directory
# to GitHub and brew. A prerequisite is to build those files using build.sh.
# use: ./scripts/release.sh cli v0.4.8 path/to/assets
set -euxo pipefail
project=$1
version=$2
assetPath=$3
if [ "$project" != "cli" ] && [ "$project" != "server" ]; then
echo "unrecognized project '$project'"
exit 1
fi
if [ -z "$version" ]; then
echo "no version specified."
exit 1
fi
if [[ $version == v* ]]; then
echo "do not prefix version with v"
exit 1
fi
# 1. push tag
version_tag="$project-v$version"
echo "* tagging and pushing the tag"
git tag -a "$version_tag" -m "Release $version_tag"
git push --tags
# 2. release on GitHub
files=("$assetPath"/*)
file_flags=()
for file in "${files[@]}"; do
file_flags+=("--attach=$file")
done
# mark as prerelease if version is not in a form of major.minor.patch
# e.g. 1.0.1-beta.1
flags=()
if [[ ! "$version" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
flags+=("--prerelease")
fi
echo "* creating release"
set -x
# first line is the title and the rest are body in markdown
message="$version_tag
Please see the [CHANGELOG](https://github.com/dnote/dnote/blob/master/CHANGELOG.md)"
hub release create \
"${file_flags[@]}" \
"${flags[@]}" \
--message="$message"\
"$version_tag"