release-flatpack.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 || exit
  16. if ! git diff-index --quiet HEAD --; then
  17. echo "There are uncommitted changes"
  18. exit 1
  19. fi
  20. BASE_BRANCH=master
  21. if [[ "$VERSION" == *"beta"* ]]; then
  22. BASE_BRANCH=beta
  23. fi
  24. git switch "${BASE_BRANCH}"
  25. git pull
  26. BRANCH=b${VERSION}
  27. git branch "${BRANCH}"
  28. git switch "${BRANCH}"
  29. echo "Updating files with version ${VERSION}, date ${VERSION_DATE} and commit ${VERSION_COMMIT}"
  30. flatpak-node-generator npm ../trilium/package-lock.json
  31. xmlstarlet ed --inplace --update "/component/releases/release/@version" --value "${VERSION}" --update "/component/releases/release/@date" --value "${VERSION_DATE}" ./com.github.zadam.trilium.metainfo.xml
  32. yq --inplace "(.modules[0].sources[0].tag = \"v${VERSION}\") | (.modules[0].sources[0].commit = \"${VERSION_COMMIT}\")" ./com.github.zadam.trilium.yml
  33. git add ./generated-sources.json
  34. git add ./com.github.zadam.trilium.metainfo.xml
  35. git add ./com.github.zadam.trilium.yml
  36. git commit -m "release $VERSION"
  37. git push --set-upstream origin "${BRANCH}"
  38. gh pr create --fill -B "${BASE_BRANCH}"
  39. gh pr merge --auto --merge --delete-branch