From 058f0db4f36754bfb955641cb73d770681296a5d Mon Sep 17 00:00:00 2001 From: Peter Squicciarini Date: Fri, 31 Aug 2018 10:53:36 -0400 Subject: [PATCH] Fix race condition (#10) * Fix race condition * Add check for GITHUB_TOKEN env var --- .travis.yml | 2 -- check_tags.sh | 56 +++++++++++++++++++++++++++++++++++++++++-------- install_deps.sh | 1 + 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3ba995a..63804a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -if: tag IS blank - matrix: include: - os: linux diff --git a/check_tags.sh b/check_tags.sh index 8f2b9d3..3f60c77 100755 --- a/check_tags.sh +++ b/check_tags.sh @@ -1,12 +1,50 @@ #!/bin/bash -if git rev-parse $LATEST_MS_TAG >/dev/null 2>&1 -then - echo "Latest MS tag ${LATEST_MS_TAG} already exists in VSCodium. Bail" -else - echo "New MS tag found, continuing build" - git config --local user.name "Travis CI" - git config --local user.email "builds@travis-ci.com" - git tag $LATEST_MS_TAG +GITHUB_RESPONSE=$(curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/vscodium/vscodium/releases/tags/$LATEST_MS_TAG) +echo "Github response: ${GITHUB_RESPONSE}" +VSCODIUM_ASSETS=$(echo $GITHUB_RESPONSE | jq '.assets') +echo "VSCodium assets: ${VSCODIUM_ASSETS}" + +# if we just don't have the github token, get out fast +if [ "$GITHUB_TOKEN" != "" ]; then + if [ "$VSCODIUM_ASSETS" != "null" ]; then + if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + HAVE_MAC=$(echo $VSCODIUM_ASSETS | jq 'map(.name) | contains(["zip"])') + if [[ "$HAVE_MAC" != "true" ]]; then + echo "Building on Mac because we have no ZIP" + export SHOULD_BUILD="yes" + fi + else + HAVE_RPM=$(echo $VSCODIUM_ASSETS | jq 'map(.name) | contains(["rpm"])') + HAVE_DEB=$(echo $VSCODIUM_ASSETS | jq 'map(.name) | contains(["deb"])') + HAVE_TAR=$(echo $VSCODIUM_ASSETS | jq 'map(.name) | contains(["tar.gz"])') + if [[ "$HAVE_RPM" != "true" ]]; then + echo "Building on Linux because we have no RPM" + export SHOULD_BUILD="yes" + fi + if [[ "$HAVE_DEB" != "true" ]]; then + echo "Building on Linux because we have no DEB" + export SHOULD_BUILD="yes" + fi + if [[ "$HAVE_TAR" != "true" ]]; then + echo "Building on Linux because we have no TAR" + export SHOULD_BUILD="yes" + fi + if [[ "$SHOULD_BUILD" != "yes" ]]; then + echo "Already have all the Linux builds" + fi + fi + else + echo "Release assets do not exist at all, continuing build" export SHOULD_BUILD="yes" -fi \ No newline at end of file + if git rev-parse $LATEST_MS_TAG >/dev/null 2>&1 + then + export TRAVIS_TAG=$LATEST_MS_TAG + else + git config --local user.name "Travis CI" + git config --local user.email "builds@travis-ci.com" + git tag $LATEST_MS_TAG + fi + fi +fi + diff --git a/install_deps.sh b/install_deps.sh index c32a4b0..82e11ed 100755 --- a/install_deps.sh +++ b/install_deps.sh @@ -5,5 +5,6 @@ if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install yarn --without-node brew install jq zip else + sudo apt-get update sudo apt-get install libx11-dev libxkbfile-dev libsecret-1-dev fakeroot rpm fi \ No newline at end of file