release.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/usr/bin/env bash
  2. export GITHUB_REPO=trilium
  3. if [[ $# -eq 0 ]] ; then
  4. echo "Missing argument of new version"
  5. exit 1
  6. fi
  7. VERSION=$1
  8. if ! [[ ${VERSION} =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-.+)?$ ]] ;
  9. then
  10. echo "Version ${VERSION} isn't in format X.Y.Z"
  11. exit 1
  12. fi
  13. if ! git diff-index --quiet HEAD --; then
  14. echo "There are uncommitted changes"
  15. exit 1
  16. fi
  17. echo "Releasing Trilium $VERSION"
  18. jq '.version = "'$VERSION'"' package.json|sponge package.json
  19. git add package.json
  20. echo 'module.exports = { buildDate:"'`date --iso-8601=seconds`'", buildRevision: "'`git log -1 --format="%H"`'" };' > src/services/build.js
  21. git add src/services/build.js
  22. TAG=v$VERSION
  23. echo "Committing package.json version change"
  24. git commit -m "release $VERSION"
  25. git push
  26. echo "Tagging commit with $TAG"
  27. git tag $TAG
  28. git push origin $TAG
  29. bin/build.sh
  30. LINUX_X64_BUILD=trilium-linux-x64-$VERSION.tar.xz
  31. DEBIAN_X64_BUILD=trilium_${VERSION}_amd64.deb
  32. WINDOWS_X64_BUILD=trilium-windows-x64-$VERSION.zip
  33. MAC_X64_BUILD=trilium-mac-x64-$VERSION.zip
  34. SERVER_BUILD=trilium-linux-x64-server-$VERSION.tar.xz
  35. echo "Creating release in GitHub"
  36. EXTRA=
  37. if [[ $TAG == *"beta"* ]]; then
  38. EXTRA=--pre-release
  39. fi
  40. github-release release \
  41. --tag $TAG \
  42. --name "$TAG release" $EXTRA
  43. echo "Uploading debian x64 package"
  44. github-release upload \
  45. --tag $TAG \
  46. --name "$DEBIAN_X64_BUILD" \
  47. --file "dist/$DEBIAN_X64_BUILD"
  48. echo "Uploading linux x64 build"
  49. github-release upload \
  50. --tag $TAG \
  51. --name "$LINUX_X64_BUILD" \
  52. --file "dist/$LINUX_X64_BUILD"
  53. echo "Uploading windows x64 build"
  54. github-release upload \
  55. --tag $TAG \
  56. --name "$WINDOWS_X64_BUILD" \
  57. --file "dist/$WINDOWS_X64_BUILD"
  58. echo "Uploading mac x64 build"
  59. github-release upload \
  60. --tag $TAG \
  61. --name "$MAC_X64_BUILD" \
  62. --file "dist/$MAC_X64_BUILD"
  63. echo "Uploading linux x64 server build"
  64. github-release upload \
  65. --tag $TAG \
  66. --name "$SERVER_BUILD" \
  67. --file "dist/$SERVER_BUILD"
  68. echo "Building docker image"
  69. bin/build-docker.sh $VERSION
  70. echo "Pushing docker image to dockerhub"
  71. bin/push-docker-image.sh $VERSION
  72. echo "Release finished!"