Skip to content

Commit 5189a27

Browse files
author
Travis CI
committed
Github release
1 parent 000d89b commit 5189a27

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

build/github_release.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ source "${DIR}/include.sh"
1010
# TRAVIS_TAG=your_release_version GITHUB_KEY=your_github_key ./build/github_release.sh
1111
# Before running this script, you will need to run "npm run build"
1212

13-
if [[ -n "${TRAVIS_TAG}" && "${TRAVIS_BRANCH}" = "master" ]]
13+
if [[ -n "${TRAVIS_TAG}" && ${TRAVIS_TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
1414
then
15+
echo "Creating release on GitHub for tag ${TRAVIS_TAG}"
1516
zip_file=$TRAVIS_TAG.zip
1617

1718
# Zip the dist folder
@@ -20,12 +21,24 @@ then
2021
# Create a release on GitHub
2122
release=$(curl -s -d "{\"tag_name\": \"$TRAVIS_TAG\"}" -H "Authorization: token ${GITHUB_KEY}" -X POST "https://api.github.com/repos/SPANDigital/presidium-js/releases")
2223

24+
if [[ $(echo $release | jq -r '.message') = "Not Found" ]]
25+
then
26+
echo "Error creating release on GitHub"
27+
exit 1
28+
fi
29+
2330
# Get the upload url from the release
2431
upload_url=$(echo $release | jq -r '.upload_url')
2532

2633
# Remove the {?name,label} from the upload_url
2734
upload_url="${upload_url//\{?name,label\}/}"
2835

36+
if [[ -z "$upload_url" ]]
37+
then
38+
echo "Error getting upload url from GitHub"
39+
exit 1
40+
fi
41+
2942
# Upload the zip file to the release
3043
curl -s -H "Authorization: token ${GITHUB_KEY}" -H "Content-Type: application/zip" --data-binary @$zip_file "$upload_url?name=$zip_file"
3144

0 commit comments

Comments
 (0)