make-release.sh 1.1 KB

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