trilium/bin/release.sh

72 lines
1.5 KiB
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
2019-07-19 02:20:38 +08:00
export GITHUB_REPO=trilium
if [[ $# -eq 0 ]] ; then
echo "Missing argument of new version"
exit 1
fi
VERSION=$1
if ! [[ ${VERSION} =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-.+)?$ ]] ;
then
echo "Version ${VERSION} isn't in format X.Y.Z"
exit 1
fi
if ! git diff-index --quiet HEAD --; then
echo "There are uncommitted changes"
exit 1
fi
2017-12-26 10:05:08 +08:00
echo "Releasing Trilium $VERSION"
2017-12-26 09:45:59 +08:00
jq '.version = "'$VERSION'"' package.json|sponge package.json
git add package.json
2018-04-10 10:30:11 +08:00
echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.js
2017-12-26 10:05:08 +08:00
2018-04-10 10:30:11 +08:00
git add src/services/build.js
TAG=v$VERSION
2017-12-26 10:05:08 +08:00
echo "Committing package.json version change"
git commit -m "release $VERSION"
git push
2017-12-26 10:05:08 +08:00
echo "Tagging commit with $TAG"
git tag $TAG
git push origin $TAG
2017-12-26 10:05:08 +08:00
bin/build.sh
LINUX_X64_BUILD=trilium-linux-x64-$VERSION.tar.xz
2019-02-21 06:22:04 +08:00
DEBIAN_X64_BUILD=trilium_${VERSION}_amd64.deb
2019-01-13 02:48:45 +08:00
WINDOWS_X64_BUILD=trilium-windows-x64-$VERSION.zip
MAC_X64_BUILD=trilium-mac-x64-$VERSION.zip
SERVER_BUILD=trilium-linux-x64-server-$VERSION.tar.xz
2017-12-26 10:05:08 +08:00
echo "Creating release in GitHub"
EXTRA=
if [[ $TAG == *"beta"* ]]; then
EXTRA=--prerelease
fi
echo "$GITHUB_CLI_AUTH_TOKEN" | gh auth login --with-token
gh release create "$TAG" \
--title "$TAG release" \
--notes "" \
$EXTRA \
"dist/$DEBIAN_X64_BUILD" \
"dist/$LINUX_X64_BUILD" \
"dist/$WINDOWS_X64_BUILD" \
"dist/$MAC_X64_BUILD" \
"dist/$SERVER_BUILD"