make-release.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. VER=$1
  3. PROJECT=$2
  4. DOTCNT=$(echo $VER | grep -o "\." | wc -l)
  5. if [ "$DOTCNT" -gt 1 ]; then
  6. PRE="true"
  7. else
  8. PRE="false"
  9. VER="${VER}.0"
  10. fi
  11. if [ -z "$PROJECT" ]; then
  12. echo "Project not specified. Exiting..."
  13. exit 0
  14. fi
  15. echo Creating a new release: $VER
  16. IFS="." read -a PARTS <<< "$VER"
  17. MAJOR=${PARTS[0]}
  18. MINOR=${PARTS[1]}
  19. MINOR=$((MINOR+1))
  20. VERN=${MAJOR}.${MINOR}
  21. pushd $GOPATH/src/v2ray.com/core
  22. echo "Adding a new tag: " "v$VER"
  23. git tag -s -a "v$VER" -m "Version ${VER}"
  24. sed -i '' "s/\(version *= *\"\).*\(\"\)/\1$VERN\2/g" core.go
  25. echo "Committing core.go (may not necessary)"
  26. git commit core.go -S -m "Update version"
  27. echo "Pushing changes"
  28. git push --follow-tags
  29. popd
  30. echo "Launching build machine."
  31. DIR="$(dirname "$0")"
  32. RAND="$(openssl rand -hex 5)"
  33. gcloud compute instances create "v2raycore-${RAND}" \
  34. --machine-type=n1-standard-2 \
  35. --metadata=release_tag=v${VER},prerelease=${PRE} \
  36. --metadata-from-file=startup-script=${DIR}/release-ci.sh \
  37. --zone=europe-west4-c \
  38. --project ${PROJECT} \
  39. --scopes "https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/devstorage.read_write" \