-
Notifications
You must be signed in to change notification settings - Fork 17
/
publish.sh
executable file
·66 lines (57 loc) · 2.26 KB
/
publish.sh
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -e
# usage: ./publish.sh <release type> <release scope> <repository>
# release type must be one of { devSnapshot, snapshot, candidate, final }
# release scope must be one of { major, minor, patch }
# repository must be one of { local, sonatype }
#
# example: ./publish.sh snapshot minor local
# will increment minor version component and publish snapshots to local maven repository
if [[ $# -ne 3 ]]
then
echo "usage: ./publish.sh <release type> <release scope> <repository>"
exit 1
fi
RELEASE_TYPE=$1
RELEASE_SCOPE=$2
REPOSITORY=$3
# check that we have a valid release scope
if [[ $RELEASE_SCOPE != 'major' && $RELEASE_SCOPE != 'minor' && $RELEASE_SCOPE != 'patch' ]]
then
echo "$RELEASE_SCOPE is not valid. (must be one of 'major', 'minor', or 'patch')."
exit 1
fi
# check that we have a valid repository
if [[ $REPOSITORY = 'sonatype' ]]
then
PUBLISH_TASK="publish"
elif [[ $REPOSITORY = 'local' ]]
then
PUBLISH_TASK="publishToMavenLocal"
else
echo "$REPOSITORY is not valid. (must be one of 'sonatype' or 'local')."
exit 1
fi
if [[ $RELEASE_TYPE = 'final' || $RELEASE_TYPE = 'candidate' ]]
then
if git remote show origin | grep "Fetch URL: [email protected]:Workday/warp-core.git"; then
echo "we are on main fork, proceeding with $RELEASE_TYPE release"
# create our repo tag
# TODO despite being in `runOnceTasks`, it appears `candidate` is run multiple times with -PallScalaVersions, incorrectly creating multiple tags
echo "creating repo tag for $RELEASE_TYPE release"
./gradlew -Prelease.scope=$RELEASE_SCOPE clean $RELEASE_TYPE
# then publish our primary module with other scala versions
echo "publishing $REPOSITORY artifacts for $RELEASE_SCOPE $RELEASE_TYPE release"
./gradlew -Prelease.useLastTag=true -PallScalaVersions $PUBLISH_TASK
else
echo "we are on a personal fork, must release from main (Workday) fork. aborting $RELEASE_TYPE release"
exit 1
fi
elif [[ $RELEASE_TYPE = 'devSnapshot' || $RELEASE_TYPE == 'snapshot' ]]
then
echo "publishing $REPOSITORY artifacts for $RELEASE_SCOPE $RELEASE_TYPE release. repo tag will not be created."
./gradlew -Prelease.scope=$RELEASE_SCOPE -PallScalaVersions clean $RELEASE_TYPE $PUBLISH_TASK
else
echo "$RELEASE_TYPE is not a valid release type"
exit 1
fi