make-release.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. pushd $GOPATH/src/v2ray.com/ext
  31. echo "Adding a new tag: " "v$VER" "to ext"
  32. git tag -s -a "v$VER" -m "Version ${VER}"
  33. echo "Pushing changes to ext"
  34. git push --follow-tags
  35. popd
  36. echo "Launching build machine."
  37. DIR="$(dirname "$0")"
  38. RAND="$(openssl rand -hex 5)"
  39. gcloud compute instances create "v2raycore-${RAND}" \
  40. --machine-type=n1-standard-2 \
  41. --metadata=release_tag=v${VER},prerelease=${PRE} \
  42. --metadata-from-file=startup-script=${DIR}/release-ci.sh \
  43. --zone=europe-west4-c \
  44. --project ${PROJECT} \
  45. --scopes "https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/devstorage.read_write" \