-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·155 lines (137 loc) · 5.65 KB
/
release.sh
File metadata and controls
executable file
·155 lines (137 loc) · 5.65 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
commit=$(git log -1 --pretty=%B | head -n 1)
version=$(echo $(cargo search voiceit3 | cut -d \" -f2) | tr "." "\n")
set -- $version
major=$1
minor=$2
patch=$3
wrapperplatformversion=$(cat ~/platformVersion)
reponame=$(basename $(git remote get-url origin) | sed 's/.\{4\}$//')
echo 'version='$version
if [[ $commit = *"RELEASE"* ]];
then
if [[ $major = "" ]] || [[ $minor = "" ]] || [[ $patch = "" ]];
then
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Packaging '$reponame' failed because script could not get current version",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
echo "Unable to get current version: cannot release." 1>&2
exit 1
fi
echo 'old version='$major'.'$minor'.'$patch
if [[ $commit = *"RELEASEMAJOR"* ]];
then
releasetype="RELEASEMAJOR"
major=$(($major+1))
minor=0
patch=0
elif [[ $commit = *"RELEASEMINOR"* ]];
then
releasetype="RELEASEMINOR"
minor=$(($minor+1))
patch=0
elif [[ $commit = *"RELEASEPATCH"* ]];
then
releasetype="RELEASEPATCH"
patch=$(($patch+1))
else
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Packaging '$reponame' failed. You need to specify RELEASEMAJOR, RELEASEMINOR, or RELEASEPATCH in the commit title",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
echo "Must specify RELEASEMAJOR, RELEASEMINOR, or RELEASEPATCH in the title." 1>&2
exit 1
fi
echo 'new version='$major'.'$minor'.'$patch
version=$major'.'$minor'.'$patch
if [[ $wrapperplatformversion = $version ]];
then
cargo login $CRATESTOKEN
cargo package 1>&2
if [ "$?" != "0" ]
then
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Command `cargo package` for '$reponame' version '$version' failed.",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
exit 1
fi
cargo publish 1>&2
if [ "$?" != "0" ]
then
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Command `cargo publish` for '$reponame' version '$version' failed.",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
exit 1
fi
curl -H "Authorization: token $GH_TOKEN" -H "Content-Type: application/json" --request POST --data '{"tag_name": "'$version'", "target_commitish": "master", "name": "'$version'", "body": "", "draft": false, "prerelease": false}' https://api.github.com/repos/voiceittech/VoiceIt3-Rust/releases &> /dev/null
if [ "$?" != "0" ]
then
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Pushing '$reponame' version '$version' to Github Release failed.",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
exit 1
fi
# Just the git commit message title
title=$(git log -1 --pretty=%B | head -n 1)
git checkout master
# Save the messages into an array called message
IFS=$'\n' message=($(git log -1 --pretty=%B | sed -e '1,2d'))
if [[ $title = *"SENDEMAIL"* ]];
then
formattedmessages=''
for i in "${message[@]}"
do
formattedmessages=$formattedmessages'|'$i
done
curl -X POST -H "X-Admin-Password: $EMAILAUTHPASS" --data-urlencode "messages=$formattedmessages" -d "packageManaged=docs" --data-urlencode "instructions=https://api.voiceit.io/?rust#introduction" "https://api.voiceit.io/platform/49"
fi
exit 0
else
curl -X POST -H 'Content-type: application/json' --data '{
"icon_url": "https://s3.amazonaws.com/voiceit-api2-testing-files/test-data/TravisCI-Mascot-1.png",
"username": "Release Wrapper Gate",
"attachments": [
{
"text": "Packaging '$reponame' version '$version' failed because the specified release version to update package management (specified by including '$releasetype' in the commit title) does not match the platform version inside the wrapper ('$wrapperplatformversion').",
"color": "danger"
}
]
}' 'https://hooks.slack.com/services/'$SLACKPARAM1'/'$SLACKPARAM2'/'$SLACKPARAM3
echo "Specified release version to update package management (specified by including "$releasetype" in the commit title) does not match the platform version in wrapper source." 1>&2
exit 1
fi
fi