aboutsummaryrefslogtreecommitdiff
path: root/publish/build_and_release.sh
diff options
context:
space:
mode:
Diffstat (limited to 'publish/build_and_release.sh')
-rw-r--r--publish/build_and_release.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/publish/build_and_release.sh b/publish/build_and_release.sh
new file mode 100644
index 0000000..5ab7fe0
--- /dev/null
+++ b/publish/build_and_release.sh
@@ -0,0 +1,43 @@
+if [ ! -s changelog.md ]; then
+ echo "Changelog is empty, refusing to publish."
+ exit 3
+fi
+
+if [[ $(git diff --cached --stat) != '' ]]
+then
+ echo "There are staged uncommitted changes, refusing to publish."
+ exit 2
+fi
+
+if [ "$#" -lt 1 ] || [ "$#" -gt 3 ]
+then
+ echo "Usage: $0 GITHUB_TOKEN CURSEFORGE_TOKEN [MODRINTH_TOKEN]"
+ exit 1
+fi
+
+# exit when any command fails
+set -e
+
+GITHUB_TOKEN=$1
+CURSEFORGE_TOKEN=$2
+MODRINTH_TOKEN=$3
+
+# build the release
+./gradlew cleanBuildAll
+
+# release
+py prepare_publish.py
+./gradlew githubRelease -PgithubToken=$GITHUB_TOKEN
+py update_updatejson.py
+
+if [ -n "$CURSEFORGE_TOKEN" ]
+then
+ ./curseforge_all.sh -PcurseToken=$CURSEFORGE_TOKEN
+fi
+
+/dev/null > changelog.md
+
+if [ -n "$MODRINTH_TOKEN" ]
+then
+ ./modrinth_all.sh -PmodrinthToken=$MODRINTH_TOKEN
+fi \ No newline at end of file