Skip to content

Instantly share code, notes, and snippets.

@mattd
Created June 1, 2015 16:56
Show Gist options
  • Save mattd/61f3ec0ce9ecd1aa1ec3 to your computer and use it in GitHub Desktop.
Save mattd/61f3ec0ce9ecd1aa1ec3 to your computer and use it in GitHub Desktop.
Github Build Upload Script
#!/bin/bash
PROJECT_NAME=something
REPO=someone/$PROJECT_NAME
API_BASE=https://api.github.com/repos/$REPO
UPLOAD_BASE=https://uploads.github.com/repos/$REPO
BUILD_ID=v`less bower.json | jq -r '.version'`-$BUILD_API
RESPONSE=$(
curl $API_BASE/releases \
-u $GITHUB_AUTH_TOKEN \
-X POST \
-H "Content-Type: application/json" \
-d '{"tag_name": "'"${BUILD_ID}"'",
"name": "'"${BUILD_ID}"'",
"body": "Automated build from WTA for some special client.",
"draft": false,
"prerelease": false}'
)
RELEASE_ID=$(echo $RESPONSE | jq '.id')
if [ "$RELEASE_ID" == "null" ]; then
exit 1
fi
cd $VCSROOT_NAME
curl $UPLOAD_BASE/releases/$RELEASE_ID/assets?name=$PROJECT_NAME-$BUILD_ID.tar.gz \
-u $GITHUB_AUTH_TOKEN \
-X POST \
-H "Content-Type: application/gzip" \
--upload-file $VCSROOT_NAME.$BUILD_NUMBER.$BUILD_VCS_NUMBER.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment