-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·52 lines (40 loc) · 2.5 KB
/
release.sh
File metadata and controls
executable file
·52 lines (40 loc) · 2.5 KB
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
#!/bin/bash
REPO="msocket"
OWNER="MobilityFirst"
USAGE='Usage: "./release.sh Description for the release notes.". To change auth token, use: export MSocketGitHubToken="YOUR_GITHUB_AUTH_TOKEN"'
if [ "$1" == "help" ]; then
echo $USAGE
exit 0
fi
if [ $# -lt 1 ]; then
echo $USAGE
exit 1
fi
#VERSION="$1" #First argument is the version
MAJOR=$(cat build.properties | grep build.major | sed 's/^build.major.number=//' | sed s/$(printf '\r')\$//)
echo $MAJOR.
MINOR=$(cat build.properties | grep build.minor | sed 's/^build.minor.number=//'| sed s/$(printf '\r')\$//)
echo $MINOR.
REVISION=$(cat build.properties | grep build.revision | sed 's/^build.revision.number=//'| sed s/$(printf '\r')\$//)
echo $REVISION.
VERSION=v$MAJOR.$MINOR.$REVISION
echo $VERSION
#DESCRIPTION="${*:2}" #Second argument and on is the description.
DESCRIPTION="$@" #The commandline argument is the description.
# First prompt for an auth token if one is not already stored.
if [ "$MSocketGitHubToken" == "" ]; then
echo "Please enter a git token that has write access to the MobilityFirst/msocket repository: "
read input
export MSocketGitHubToken="$input"
fi
# Create a new release on github
curl --data '{"tag_name": "'"$VERSION"'","target_commitish": "master","name": "'"$VERSION"'","body": "'"$DESCRIPTION"'","draft": false,"prerelease": false}' https://api.github.com/repos/$OWNER/$REPO/releases?access_token=$MSocketGitHubToken
RELEASEID=$(curl "https://api.github.com/repos/$OWNER/$REPO/releases/tags/$VERSION" | grep id\": | sed 's/.*id": //' | sed 's/,$//' | grep [0-9][0-9]* -m 1 )
#curl "https://api.github.com/repos/$OWNER/$REPO/releases/tags/$VERSION" > testFile2.txt
echo "ID: $RELEASEID"
MSOCKET="msocket-$MAJOR.$MINOR.$REVISION.jar"
MSOCKETPROXY="msocket-proxy-console-$MAJOR.$MINOR.$REVISION.jar"
#echo "https://api.github.com/repos/$OWNER/$REPO/releases/$RELEASEID/assets?name=$TARNAME&access_token=$MSocketGitHubToken"
curl -X POST --header "Content-Type:application/gzip" --data-binary @"jars/$MSOCKET" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASEID/assets?name=$MSOCKET&access_token=$MSocketGitHubToken"
curl -X POST --header "Content-Type:application/gzip" --data-binary @"jars/$MSOCKETPROXY" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASEID/assets?name=$MSOCKETPROXY&access_token=$MSocketGitHubToken"
curl -X POST --header "Content-Type:text/plain" --data-binary @"LICENSE.txt" "https://uploads.github.com/repos/$OWNER/$REPO/releases/$RELEASEID/assets?name=LICENSE.txt&access_token=$MSocketGitHubToken"