update release ci script

pull/432/head
Darien Raymond 2017-02-23 13:13:11 +01:00
parent 6db9b8ba12
commit 2b62de2db6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 51 additions and 38 deletions

View File

@ -3,15 +3,16 @@
set -x
apt-get update
apt-get -y install jq
apt-get -y install jq git file
function getattr() {
curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/$1
curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/$2/attributes/$1
}
GITHUB_TOKEN=$(getattr "github_token")
RELEASE_TAG=$(getattr "release_tag")
RELEASE_ID=$(curl -L -s https://api.github.com/repos/v2ray/v2ray-core/releases/tags/${RELEASE_TAG} | jq ".id")
GITHUB_TOKEN=$(getattr "github_token" "project")
RELEASE_TAG=$(getattr "release_tag" "instance")
PRERELEASE=$(getattr "prerelease" "instance")
DOCKER_HUB_KEY=$(getattr "docker_hub_key" "project")
mkdir -p /v2ray/build
@ -26,8 +27,15 @@ mkdir -p /v2ray/src
export GOPATH=/v2ray
go get -u v2ray.com/core/...
pushd $GOPATH/src/v2ray.com/core/
git checkout tags/${RELEASE_TAG}
popd
go install v2ray.com/core/tools/build
export TRAVIS_TAG=${RELEASE_TAG}
$GOPATH/bin/build --os=windows --arch=x86 --zip
$GOPATH/bin/build --os=windows --arch=x64 --zip
$GOPATH/bin/build --os=macos --arch=x64 --zip
@ -44,50 +52,55 @@ $GOPATH/bin/build --os=freebsd --arch=amd64 --zip
$GOPATH/bin/build --os=openbsd --arch=x86 --zip
$GOPATH/bin/build --os=openbsd --arch=amd64 --zip
JSON_DATA=$(printf '{"tag_name": "%s", "prerelease": "%s"}' ${RELEASE_TAG} ${PRERELEASE})
RELEASE_ID=$(curl --data "${JSON_DATA}" -H "Authorization: token ${GITHUB_TOKEN}" -X POST https://api.github.com/repos/v2ray/v2ray-core/releases | jq ".id")
function upload() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
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)"
}
echo $(upload $GOPATH/bin/v2ray-macos.zip)
echo $(upload $GOPATH/bin/v2ray-windows-64.zip)
echo $(upload $GOPATH/bin/v2ray-windows-32.zip)
echo $(upload $GOPATH/bin/v2ray-linux-64.zip)
echo $(upload $GOPATH/bin/v2ray-linux-32.zip)
echo $(upload $GOPATH/bin/v2ray-linux-arm.zip)
echo $(upload $GOPATH/bin/v2ray-linux-arm64.zip)
echo $(upload $GOPATH/bin/v2ray-linux-mips64.zip)
echo $(upload $GOPATH/bin/v2ray-linux-mips64le.zip)
echo $(upload $GOPATH/bin/v2ray-linux-mips.zip)
echo $(upload $GOPATH/bin/v2ray-linux-mipsle.zip)
echo $(upload $GOPATH/bin/v2ray-freebsd-64.zip)
echo $(upload $GOPATH/bin/v2ray-freebsd-32.zip)
echo $(upload $GOPATH/bin/v2ray-openbsd-64.zip)
echo $(upload $GOPATH/bin/v2ray-openbsd-32.zip)
echo $(upload $GOPATH/bin/metadata.txt)
upload $GOPATH/bin/v2ray-macos.zip
upload $GOPATH/bin/v2ray-windows-64.zip
upload $GOPATH/bin/v2ray-windows-32.zip
upload $GOPATH/bin/v2ray-linux-64.zip
upload $GOPATH/bin/v2ray-linux-32.zip
upload $GOPATH/bin/v2ray-linux-arm.zip
upload $GOPATH/bin/v2ray-linux-arm64.zip
upload $GOPATH/bin/v2ray-linux-mips64.zip
upload $GOPATH/bin/v2ray-linux-mips64le.zip
upload $GOPATH/bin/v2ray-linux-mips.zip
upload $GOPATH/bin/v2ray-linux-mipsle.zip
upload $GOPATH/bin/v2ray-freebsd-64.zip
upload $GOPATH/bin/v2ray-freebsd-32.zip
upload $GOPATH/bin/v2ray-openbsd-64.zip
upload $GOPATH/bin/v2ray-openbsd-32.zip
upload $GOPATH/bin/metadata.txt
if [[ "${PRERELEASE}" == "false" ]]; then
INSTALL_DIR=/v2ray/src/github.com/v2ray/install
#INSTALL_DIR=_install
git clone "https://github.com/v2ray/install.git" ${INSTALL_DIR}
#git clone "https://github.com/v2ray/install.git" ${INSTALL_DIR}
RELEASE_DIR=${INSTALL_DIR}/releases/${RELEASE_TAG}
mkdir -p ${RELEASE_DIR}/
cp $GOPATH/bin/metadata.txt ${RELEASE_DIR}/
cp $GOPATH/bin/v2ray-*.zip ${RELEASE_DIR}/
echo ${RELEASE_TAG} > ${INSTALL_DIR}/releases/latest.txt
#RELEASE_DIR=${INSTALL_DIR}/releases/${TRAVIS_TAG}
#mkdir -p ${RELEASE_DIR}/
#cp $GOPATH/bin/metadata.txt ${RELEASE_DIR}/
#cp $GOPATH/bin/v2ray-*.zip ${RELEASE_DIR}/
#echo ${TRAVIS_TAG} > ${INSTALL_DIR}/releases/latest.txt
cp $GOPATH/bin/v2ray-${RELEASE_TAG}-linux-64/v2ray ${INSTALL_DIR}/docker/official/
#cp $GOPATH/bin/v2ray-${TRAVIS_TAG}-linux-64/v2ray ${INSTALL_DIR}/docker/official/
pushd ${INSTALL_DIR}
git config user.name "V2Ray Auto Build"
git config user.email "admin@v2ray.com"
git add -A
git commit -m "Update for ${RELEASE_TAG}"
git push "https://${GITHUB_TOKEN}@github.com/v2ray/install.git" master
popd
#pushd ${INSTALL_DIR}
#git config user.name "V2Ray Auto Build"
#git config user.email "admin@v2ray.com"
#git add -A
#git commit -m "Update for ${TRAVIS_TAG}"
#git push "https://${GIT_KEY_INSTALL}@github.com/v2ray/install.git" master
#popd
DOCKER_HUB_API=https://registry.hub.docker.com/u/v2ray/official/trigger/${DOCKER_HUB_KEY}/
curl -H "Content-Type: application/json" --data '{"build": true}' -X POST "${DOCKER_HUB_API}"
#DOCKER_HUB_API=https://registry.hub.docker.com/u/v2ray/official/trigger/${DOCKER_HUB_KEY}/
#curl -H "Content-Type: application/json" --data '{"build": true}' -X POST "${DOCKER_HUB_API}"
fi