2015-09-16 10:30:17 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-02-23 06:00:23 -05:00
|
|
|
set -x
|
|
|
|
|
|
|
|
apt-get update
|
2018-10-07 08:26:22 -04:00
|
|
|
apt-get -y install \
|
|
|
|
jq `# for parsing Github API` \
|
|
|
|
git `# for go get` \
|
|
|
|
file `# for Github upload` \
|
|
|
|
pkg-config zip g++ zlib1g-dev unzip python `# for Bazel` \
|
|
|
|
openssl `# for binary digest` \
|
|
|
|
|
2018-10-05 07:25:59 -04:00
|
|
|
|
2017-02-23 06:00:23 -05:00
|
|
|
function getattr() {
|
2017-02-23 07:13:11 -05:00
|
|
|
curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/$2/attributes/$1
|
2017-02-23 06:00:23 -05:00
|
|
|
}
|
|
|
|
|
2017-02-23 07:13:11 -05:00
|
|
|
GITHUB_TOKEN=$(getattr "github_token" "project")
|
|
|
|
RELEASE_TAG=$(getattr "release_tag" "instance")
|
|
|
|
PRERELEASE=$(getattr "prerelease" "instance")
|
|
|
|
DOCKER_HUB_KEY=$(getattr "docker_hub_key" "project")
|
2017-02-23 08:48:44 -05:00
|
|
|
SIGN_KEY_PATH=$(getattr "sign_key_path" "project")
|
|
|
|
SIGN_KEY_PASS=$(getattr "sign_key_pass" "project")
|
2017-04-21 07:26:54 -04:00
|
|
|
VUSER=$(getattr "b_user" "project")
|
2017-02-23 06:00:23 -05:00
|
|
|
|
2018-10-04 15:00:20 -04:00
|
|
|
mkdir -p /v2/build
|
|
|
|
|
|
|
|
pushd /v2/build
|
2019-02-28 15:12:20 -05:00
|
|
|
BAZEL_VER=0.23.0
|
2018-10-04 15:00:20 -04:00
|
|
|
curl -L -O https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh
|
|
|
|
chmod +x bazel-${BAZEL_VER}-installer-linux-x86_64.sh
|
|
|
|
./bazel-${BAZEL_VER}-installer-linux-x86_64.sh
|
|
|
|
popd
|
2017-02-23 06:00:23 -05:00
|
|
|
|
2018-11-05 11:13:35 -05:00
|
|
|
gsutil cp ${SIGN_KEY_PATH} /v2/build/sign_key.asc
|
|
|
|
echo ${SIGN_KEY_PASS} | gpg --passphrase-fd 0 --batch --import /v2/build/sign_key.asc
|
2017-02-23 08:48:44 -05:00
|
|
|
|
2018-11-05 11:13:35 -05:00
|
|
|
curl -L -o /v2/build/releases https://api.github.com/repos/v2ray/v2ray-core/releases
|
2017-02-23 06:00:23 -05:00
|
|
|
|
|
|
|
GO_INSTALL=golang.tar.gz
|
2019-02-01 10:53:21 -05:00
|
|
|
curl -L -o ${GO_INSTALL} https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz
|
2017-02-23 06:00:23 -05:00
|
|
|
tar -C /usr/local -xzf ${GO_INSTALL}
|
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
|
|
|
2018-10-04 15:00:20 -04:00
|
|
|
mkdir -p /v2/src
|
|
|
|
export GOPATH=/v2
|
2017-02-23 06:00:23 -05:00
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
# Download all source code
|
2019-10-10 03:14:50 -04:00
|
|
|
go get -insecure -t v2ray.com/core/...
|
|
|
|
go get -insecure -t v2ray.com/ext/...
|
2017-02-23 07:13:11 -05:00
|
|
|
|
|
|
|
pushd $GOPATH/src/v2ray.com/core/
|
|
|
|
git checkout tags/${RELEASE_TAG}
|
|
|
|
|
2018-10-04 15:00:20 -04:00
|
|
|
VERN=${RELEASE_TAG:1}
|
|
|
|
BUILDN=`date +%Y%m%d`
|
|
|
|
sed -i "s/\(version *= *\"\).*\(\"\)/\1$VERN\2/g" core.go
|
|
|
|
sed -i "s/\(build *= *\"\).*\(\"\)/\1$BUILDN\2/g" core.go
|
2018-10-06 19:26:04 -04:00
|
|
|
popd
|
|
|
|
|
2019-01-05 02:54:47 -05:00
|
|
|
pushd $GOPATH/src/v2ray.com/core/
|
2018-11-09 05:27:17 -05:00
|
|
|
# Update geoip.dat
|
|
|
|
GEOIP_TAG=$(curl --silent "https://api.github.com/repos/v2ray/geoip/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
|
curl -L -o release/config/geoip.dat "https://github.com/v2ray/geoip/releases/download/${GEOIP_TAG}/geoip.dat"
|
2019-01-05 02:54:47 -05:00
|
|
|
sleep 1
|
2018-11-09 05:27:17 -05:00
|
|
|
|
2018-12-11 10:45:20 -05:00
|
|
|
# Update geosite.dat
|
2019-01-05 02:54:47 -05:00
|
|
|
GEOSITE_TAG=$(curl --silent "https://api.github.com/repos/v2ray/domain-list-community/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
|
|
|
|
curl -L -o release/config/geosite.dat "https://github.com/v2ray/domain-list-community/releases/download/${GEOSITE_TAG}/dlc.dat"
|
|
|
|
sleep 1
|
|
|
|
popd
|
2018-12-11 10:45:20 -05:00
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
# Take a snapshot of all required source code
|
|
|
|
pushd $GOPATH/src
|
2018-12-04 12:50:53 -05:00
|
|
|
|
|
|
|
# Create zip file for all sources
|
2018-10-06 19:26:04 -04:00
|
|
|
zip -9 -r /v2/build/src_all.zip * -x '*.git*'
|
|
|
|
popd
|
2018-10-04 15:00:20 -04:00
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
pushd $GOPATH/src/v2ray.com/core/
|
2018-10-04 15:00:20 -04:00
|
|
|
bazel build --action_env=GOPATH=$GOPATH --action_env=PATH=$PATH --action_env=GPG_PASS=${SIGN_KEY_PASS} //release:all
|
|
|
|
popd
|
2017-10-25 11:26:42 -04:00
|
|
|
|
2017-12-28 18:27:24 -05:00
|
|
|
RELBODY="https://www.v2ray.com/chapter_00/01_versions.html"
|
2017-10-24 18:23:22 -04:00
|
|
|
JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"")
|
|
|
|
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".prerelease=${PRERELEASE}")
|
2018-01-12 07:27:18 -05:00
|
|
|
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".body=\"${RELBODY}\"")
|
2017-02-23 07:13:11 -05:00
|
|
|
RELEASE_ID=$(curl --data "${JSON_DATA}" -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/v2ray/v2ray-core/releases | jq ".id")
|
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
function uploadfile() {
|
2017-02-23 06:00:23 -05:00
|
|
|
FILE=$1
|
|
|
|
CTYPE=$(file -b --mime-type $FILE)
|
2018-12-06 16:53:23 -05:00
|
|
|
|
|
|
|
sleep 1
|
2019-02-06 11:16:55 -05:00
|
|
|
curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2ray/v2ray-core/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
|
|
|
|
sleep 1
|
2017-02-23 06:00:23 -05:00
|
|
|
}
|
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
function upload() {
|
|
|
|
FILE=$1
|
|
|
|
DGST=$1.dgst
|
|
|
|
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >> $DGST
|
|
|
|
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >> $DGST
|
|
|
|
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >> $DGST
|
|
|
|
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >> $DGST
|
|
|
|
uploadfile $FILE
|
|
|
|
uploadfile $DGST
|
|
|
|
}
|
|
|
|
|
2018-10-04 15:00:20 -04:00
|
|
|
ART_ROOT=$GOPATH/src/v2ray.com/core/bazel-bin/release
|
2018-10-06 19:26:04 -04:00
|
|
|
|
2018-10-04 15:00:20 -04:00
|
|
|
upload ${ART_ROOT}/v2ray-macos.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-windows-64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-windows-32.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-32.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-arm.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-arm64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-mips64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-mips64le.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-mips.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-mipsle.zip
|
2018-11-01 07:23:01 -04:00
|
|
|
upload ${ART_ROOT}/v2ray-linux-ppc64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-linux-ppc64le.zip
|
2018-10-04 15:00:20 -04:00
|
|
|
upload ${ART_ROOT}/v2ray-linux-s390x.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-freebsd-64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-freebsd-32.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-openbsd-64.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-openbsd-32.zip
|
|
|
|
upload ${ART_ROOT}/v2ray-dragonfly-64.zip
|
2018-10-06 19:26:04 -04:00
|
|
|
upload /v2/build/src_all.zip
|
2017-02-23 07:13:11 -05:00
|
|
|
|
|
|
|
if [[ "${PRERELEASE}" == "false" ]]; then
|
|
|
|
|
2018-08-02 17:13:06 -04:00
|
|
|
DOCKER_HUB_API=https://cloud.docker.com/api/build/v1/source/62bfa37d-18ef-4b66-8f1a-35f9f3d4438b/trigger/65027872-e73e-4177-8c6c-6448d2f00d5b/call/
|
2017-02-23 07:13:11 -05:00
|
|
|
curl -H "Content-Type: application/json" --data '{"build": true}' -X POST "${DOCKER_HUB_API}"
|
|
|
|
|
2018-10-05 07:25:59 -04:00
|
|
|
# Update homebrew
|
|
|
|
pushd ${ART_ROOT}
|
|
|
|
V_HASH256=$(sha256sum v2ray-macos.zip | cut -d ' ' -f 1)
|
|
|
|
popd
|
|
|
|
|
|
|
|
echo "SHA256: ${V_HASH256}"
|
|
|
|
echo "Version: ${VERN}"
|
|
|
|
|
|
|
|
DOWNLOAD_URL="https://github.com/v2ray/v2ray-core/releases/download/v${VERN}/v2ray-macos.zip"
|
|
|
|
|
|
|
|
cd $GOPATH/src/v2ray.com/
|
|
|
|
git clone https://github.com/v2ray/homebrew-v2ray.git
|
|
|
|
|
|
|
|
echo "Updating config"
|
|
|
|
|
|
|
|
cd homebrew-v2ray
|
|
|
|
|
|
|
|
sed -i "s#^\s*url.*# url \"$DOWNLOAD_URL\"#g" Formula/v2ray-core.rb
|
|
|
|
sed -i "s#^\s*sha256.*# sha256 \"$V_HASH256\"#g" Formula/v2ray-core.rb
|
|
|
|
sed -i "s#^\s*version.*# version \"$VERN\"#g" Formula/v2ray-core.rb
|
|
|
|
|
|
|
|
echo "Updating repo"
|
|
|
|
|
2018-10-06 19:26:04 -04:00
|
|
|
git config user.name "Darien Raymond"
|
|
|
|
git config user.email "admin@v2ray.com"
|
|
|
|
|
2018-10-05 07:25:59 -04:00
|
|
|
git commit -am "update to version $VERN"
|
|
|
|
git push --quiet "https://${GITHUB_TOKEN}@github.com/v2ray/homebrew-v2ray" master:master
|
|
|
|
|
2019-01-14 15:26:43 -05:00
|
|
|
echo "Updating dist"
|
|
|
|
|
|
|
|
cd $GOPATH/src/v2ray.com/
|
|
|
|
mkdir dist
|
|
|
|
cd dist
|
|
|
|
|
|
|
|
git init
|
|
|
|
git config user.name "Darien Raymond"
|
|
|
|
git config user.email "admin@v2ray.com"
|
|
|
|
|
|
|
|
cp ${ART_ROOT}/v2ray-macos.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-windows-64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-windows-32.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-32.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-arm.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-arm64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-mips64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-mips64le.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-mips.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-mipsle.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-ppc64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-ppc64le.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-linux-s390x.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-freebsd-64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-freebsd-32.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-openbsd-64.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-openbsd-32.zip .
|
|
|
|
cp ${ART_ROOT}/v2ray-dragonfly-64.zip .
|
|
|
|
cp /v2/build/src_all.zip .
|
2019-02-08 04:41:55 -05:00
|
|
|
cp "$GOPATH/src/v2ray.com/core/release/install-release.sh" ./install.sh
|
2019-02-07 18:10:03 -05:00
|
|
|
|
2019-02-08 04:41:55 -05:00
|
|
|
sed -i "s/^NEW_VER=\"\"$/NEW_VER=\"${RELEASE_TAG}\"/" install.sh
|
|
|
|
sed -i 's/^DIST_SRC=".*"$/DIST_SRC="jsdelivr"/' install.sh
|
2019-01-14 15:26:43 -05:00
|
|
|
|
|
|
|
git add .
|
|
|
|
git commit -m "Version ${RELEASE_TAG}"
|
2019-01-14 15:27:42 -05:00
|
|
|
git tag -a "${RELEASE_TAG}" -m "Version ${RELEASE_TAG}"
|
2019-01-14 15:26:43 -05:00
|
|
|
git remote add origin "https://${GITHUB_TOKEN}@github.com/v2ray/dist"
|
2019-01-20 14:23:42 -05:00
|
|
|
git push -u --force --follow-tags origin master
|
2019-01-14 15:26:43 -05:00
|
|
|
|
2017-02-23 07:13:11 -05:00
|
|
|
fi
|
2017-04-04 17:11:52 -04:00
|
|
|
|
2018-10-05 07:25:59 -04:00
|
|
|
shutdown -h now
|