aboutsummaryrefslogtreecommitdiff
path: root/publish/build_and_release.sh
blob: 5ab7fe05aa782734d3122576596ce08e13caa604 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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