release-flatpack.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. if [[ $# -eq 0 ]] ; then
  3. echo "Missing argument of new version"
  4. exit 1
  5. fi
  6. VERSION=$1
  7. if ! [[ ${VERSION} =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}(-.+)?$ ]] ;
  8. then
  9. echo "Version ${VERSION} isn't in format X.Y.Z"
  10. exit 1
  11. fi
  12. VERSION_DATE=$(git log -1 --format=%aI "v${VERSION}" | cut -c -10)
  13. VERSION_COMMIT=$(git rev-list -n 1 "v${VERSION}")
  14. # expecting the directory at a specific path
  15. cd ~/trilium-flathub
  16. if ! git diff-index --quiet HEAD --; then
  17. echo "There are uncommitted changes"
  18. exit 1
  19. fi
  20. if [[ "$VERSION" == *"beta"* ]]; then
  21. git switch beta
  22. else
  23. git switch master
  24. fi
  25. git pull
  26. echo "Updating files with version ${VERSION}, date ${VERSION_DATE} and commit ${VERSION_COMMIT}"
  27. flatpak-node-generator npm ../trilium/package-lock.json
  28. xmlstarlet ed --inplace --update "/component/releases/release/@version" --value "${VERSION}" --update "/component/releases/release/@date" --value "${VERSION_DATE}" ./com.github.zadam.trilium.metainfo.xml
  29. yq --inplace "(.modules[0].sources[0].tag = \"v${VERSION}\") | (.modules[0].sources[0].commit = \"${VERSION_COMMIT}\")" ./com.github.zadam.trilium.yml
  30. git add ./generated-sources.json
  31. git add ./com.github.zadam.trilium.metainfo.xml
  32. git add ./com.github.zadam.trilium.yml
  33. git commit -m "release $VERSION"
  34. git push