fbshipit-source-id: b14273e883aba6de7b817801a1b04e54a29a6366
This commit is contained in:
@@ -1,48 +1,24 @@
|
||||
#!/bin/bash
|
||||
TOKEN=$(secrets_tool get SONAR_GITHUB_TOKEN)
|
||||
GITHUB_ORG="facebook"
|
||||
GITHUB_REPO="Sonar"
|
||||
|
||||
cd ../../ || exit
|
||||
echo "✨ Creating new Sonar release on GitHub..."
|
||||
MAJOR=$(curl -x fwdproxy:8080 --silent https://raw.githubusercontent.com/facebook/Sonar/master/package.json | jq -r '.version' | sed -E 's/[0-9]+$//g')
|
||||
|
||||
function jsonValue() {
|
||||
python -c 'import json,sys;obj=json.load(sys.stdin);print obj["'$1'"]' || echo ''
|
||||
}
|
||||
echo "What should the patch version of the next release be? (v${MAJOR}_)"
|
||||
|
||||
git -c http.proxy=fwdproxy:8080 -c https.proxy=fwdproxy:8080 clone https://github.com/facebook/Sonar.git sonar-public
|
||||
cp sonar/scripts/sandcastle-build.sh sonar-public/scripts/sandcastle-build.sh
|
||||
# third-party dependencies are not on github, so we need to copy them in place
|
||||
cp -r sonar/third-party sonar-public/third-party
|
||||
cd sonar-public/scripts && ./sandcastle-build.sh "$(git rev-list HEAD --count || echo 0)"
|
||||
|
||||
VERSION=$(plutil -p ./sonar-public/dist/mac/Sonar.app/Contents/Info.plist | awk '/CFBundleShortVersionString/ {print substr($3, 2, length($3)-2)}')
|
||||
|
||||
RELEASE_JSON=$(curl -x fwdproxy:8080 --silent --data '{
|
||||
"tag_name": "v'$VERSION'",
|
||||
"target_commitish": "master",
|
||||
"name": "v'$VERSION'",
|
||||
"body": "",
|
||||
"draft": false,
|
||||
"prerelease": false
|
||||
}' https://api.github.com/repos/$GITHUB_ORG/$GITHUB_REPO/releases?access_token=$TOKEN)
|
||||
|
||||
RELEASE_ID=$(echo $RELEASE_JSON | jsonValue id)
|
||||
|
||||
if [ -z "${RELEASE_ID}" ]; then
|
||||
echo $RELEASE_JSON
|
||||
exit 1
|
||||
read -r VERSION
|
||||
if ! [[ $VERSION =~ ^[0-9]+$ ]] ; then
|
||||
echo "error: Version needs to be a number" >&2; exit 1
|
||||
fi
|
||||
|
||||
echo "Created GitHub release ID: $RELEASE_ID"
|
||||
UPLOAD_URL=$(echo $RELEASE_JSON | jsonValue upload_url| sed -e 's#{?name,label}##')
|
||||
ASSET_JSON=$(curl -x fwdproxy:8080 --silent $UPLOAD_URL'?access_token='$TOKEN'&name=Sonar.zip' --header 'Content-Type: application/zip' --upload-file ./sonar-public/dist/Sonar.zip -X POST)
|
||||
echo "Creating version $MAJOR$VERSION and releasing to GitHub..."
|
||||
TMP_DIR=$(mktemp -d)
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
JSON=$(cat "$DIR/public-build.json")
|
||||
JSON=${JSON/__VERSION__/$VERSION}
|
||||
JSON=${JSON/__USER__/$USER}
|
||||
echo "$JSON" > "$TMP_DIR/job.json"
|
||||
|
||||
DOWNLOAD_URL=$(echo $ASSET_JSON | jsonValue browser_download_url)
|
||||
scutil create "$TMP_DIR/job.json"
|
||||
echo "✅ GitHub release will be automatically created once the Sandcastle job finishes."
|
||||
|
||||
if [ -z "${DOWNLOAD_URL}" ]; then
|
||||
echo $ASSET_JSON
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Released Sonar v$VERSION"
|
||||
echo "Download: $DOWNLOAD_URL"
|
||||
rm -rf "$TMP_DIR"
|
||||
|
||||
Reference in New Issue
Block a user