update.sh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. BASEDIR=$(dirname "$0")
  3. cd "${BASEDIR}" || exit 1
  4. BASEDIR=$(pwd)
  5. set -x
  6. source config.sh
  7. if [ -f config/config_local.sh ]; then
  8. source config/config_local.sh
  9. fi
  10. MODE=${MODE:-develop}
  11. BRANCH_var="BRANCH_$MODE"
  12. BRANCH="${!BRANCH_var}"
  13. function fail_in {
  14. upstream_git reset --hard HEAD
  15. exit 1
  16. }
  17. function fail_out {
  18. polymc_git reset --hard HEAD
  19. exit 1
  20. }
  21. function upstream_git {
  22. git -C "${BASEDIR}/${UPSTREAM_DIR}" "$@"
  23. }
  24. function polymc_git {
  25. git -C "${BASEDIR}/${PMC_DIR}" "$@"
  26. }
  27. # make sure we *could* push to our repo
  28. currentDate=$(date --iso-8601)
  29. upstream_git reset --hard HEAD || exit 1
  30. upstream_git checkout "${BRANCH}" || exit 1
  31. python updateMojang.py || fail_in
  32. python updateForge.py || fail_in
  33. python updateNeoforge.py || fail_in
  34. python updateFabric.py || fail_in
  35. python updateQuilt.py || fail_in
  36. python updateLiteloader.py || fail_in
  37. if [ "${DEPLOY_TO_GIT}" = true ] ; then
  38. upstream_git add mojang/version_manifest_v2.json mojang/versions/* mojang/assets/* || fail_in
  39. upstream_git add forge/*.json forge/version_manifests/*.json forge/installer_manifests/*.json forge/files_manifests/*.json forge/installer_info/*.json || fail_in
  40. upstream_git add neoforge/*.json neoforge/installer_manifests/*.json neoforge/version_manifests/*.json neoforge/installer_hashes/*.txt || fail_in
  41. upstream_git add fabric/loader-installer-json/*.json fabric/meta-v2/*.json fabric/jars/*.json || fail_in
  42. upstream_git add quilt/loader-installer-json/*.json quilt/meta-v3/*.json quilt/jars/*.json || fail_in
  43. upstream_git add liteloader/*.json || fail_in
  44. if ! upstream_git diff --cached --exit-code ; then
  45. upstream_git commit -a -m "Update ${currentDate}" || fail_in
  46. upstream_git push || exit 1
  47. fi
  48. fi
  49. polymc_git reset --hard HEAD || exit 1
  50. polymc_git checkout "${BRANCH}" || exit 1
  51. python generateMojang.py || fail_out
  52. python generateForge.py || fail_out
  53. python generateNeoforge.py || fail_out
  54. python generateFabric.py || fail_out
  55. python generateQuilt.py || fail_out
  56. python generateLiteloader.py || fail_out
  57. python index.py || fail_out
  58. if [ "${DEPLOY_TO_GIT}" = true ] ; then
  59. polymc_git add index.json org.lwjgl/* org.lwjgl3/* net.minecraft/* || fail_out
  60. polymc_git add net.minecraftforge/* || fail_out
  61. polymc_git add net.neoforged.neoforge/* || fail_out
  62. polymc_git add net.fabricmc.fabric-loader/* net.fabricmc.intermediary/* || fail_out
  63. polymc_git add org.quiltmc.quilt-loader/* || fail_out # TODO: add Quilt hashed, once it is actually used
  64. polymc_git add com.mumfrey.liteloader/* || fail_out
  65. if ! polymc_git diff --cached --exit-code ; then
  66. polymc_git commit -a -m "Update ${currentDate}" || fail_out
  67. polymc_git push || exit 1
  68. fi
  69. fi
  70. if [ "${DEPLOY_TO_FOLDER}" = true ] ; then
  71. DEPLOY_FOLDER_var="DEPLOY_FOLDER_$MODE"
  72. DEPLOY_FOLDER="${!DEPLOY_FOLDER_var}"
  73. echo "Deploying to ${DEPLOY_FOLDER}"
  74. rsync -rvog --chown="${DEPLOY_FOLDER_USER}:${DEPLOY_FOLDER_GROUP}" --exclude=.git "${BASEDIR}/${PMC_DIR}/" "${DEPLOY_FOLDER}"
  75. fi
  76. exit 0