1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 09:50:43 +00:00

Migrate release from Azure Pipelines to GitHub Actions (#453)

This commit is contained in:
Loyalsoldier 2020-11-26 16:30:17 +08:00 committed by GitHub
parent b93f69fb48
commit ea0210acee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 149 additions and 256 deletions

81
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,81 @@
name: Release
on:
release:
types: [prereleased]
push:
branches:
- master
- v*
- dev*
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
- ".github/workflows/*.yaml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
- ".github/workflows/*.yaml"
jobs:
release:
if: github.repository != 'v2ray/v2ray-core'
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Checkout codebase
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get project dependencies
run: go mod download
- name: Set variables
run: |
echo "BleedingReleaseTag=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "TagReleaseTag=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
shell: bash
- name: Build binaries
run: bazel build --action_env=PATH=$PATH --action_env=GOPATH=$(go env GOPATH) --action_env=GOCACHE=$(go env GOCACHE) --action_env=SPWD=$(pwd) --spawn_strategy local //release:all
- name: Upload binaries to repo "v2fly/V2FlyBleedingEdgeBinary"
if: github.event_name != 'release' && github.repository == 'v2fly/v2ray-core'
env:
IsBleedingRelease: true
WORKDIR: ${{ github.workspace }}
PRERELEASE: true
RELEASE_SHA: ${{ github.sha }}
RELEASE_TAG: ${{ env.BleedingReleaseTag }}
UPLOAD_REPO: v2fly/V2FlyBleedingEdgeBinary
PERSONAL_TOKEN: ${{ secrets.BLEEDINGEDGEBINARY_REPO_TOKEN }}
COMMENT_TARGETTED_REPO_OWNER: v2fly
COMMENT_TARGETTED_REPO_NAME: v2ray-core
run: |
chmod u+x ./release/release.sh
./release/release.sh
- name: Upload binaries to current repo
if: github.event_name == 'release'
env:
IsBleedingRelease: false
WORKDIR: ${{ github.workspace }}
PRERELEASE: true
RELEASE_SHA: ${{ github.sha }}
RELEASE_TAG: ${{ env.TagReleaseTag }}
UPLOAD_REPO: ${{ github.repository }}
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
chmod u+x ./release/release.sh
./release/release.sh

View File

@ -1,54 +0,0 @@
trigger:
batch: true
branches:
include:
- master
- dev*
- refs/tags/*
pool:
vmImage: "ubuntu-latest"
variables:
- group: GithubToken
steps:
- checkout: self
- task: GoTool@0
inputs:
version: "1.15.5"
- script: |
go version
go mod download
workingDirectory: $(system.defaultWorkingDirectory)
displayName: "Fetch sources"
- script: |
bazel build --action_env=PATH=$PATH --action_env=GOPATH=$(go env GOPATH) --action_env=GOCACHE=$(go env GOCACHE) --action_env=SPWD=$(pwd) --spawn_strategy local //release:all
workingDirectory: $(system.defaultWorkingDirectory)
displayName: "Build Binaries"
- script: |
echo $RELEASE_TAG
./release/bleedingrelease.sh
workingDirectory: $(system.defaultWorkingDirectory)
displayName: "Generate Bleeding Edge Release"
env:
WORKDIR: $(system.defaultWorkingDirectory)
PERSONAL_TOKEN: $(GITHUB_TOKEN)
PRERELEASE: true
RELEASE_TAG: unstable-$(Build.SourceVersion)
RELEASE_SHA: $(Build.SourceVersion)
TRIGGER_REASON: $(Build.SourceBranch)
COMMENT_TARGETTED_REPO_OWNER: v2fly
COMMENT_TARGETTED_REPO_NAME: v2ray-core
- script: |
echo $RELEASE_TAG
./release/tagrelease.sh
workingDirectory: $(system.defaultWorkingDirectory)
displayName: "Generate Tag Release"
env:
WORKDIR: $(system.defaultWorkingDirectory)
PERSONAL_TOKEN: $(GITHUB_TOKEN)
PRERELEASE: true
RELEASE_TAG: unstable-$(Build.SourceVersion)
RELEASE_SHA: $(Build.SourceVersion)
TRIGGER_REASON: $(Build.SourceBranch)

View File

@ -1,94 +0,0 @@
#!/usr/bin/env bash
RELBODY="https://github.com/v2fly/v2ray-core/commit/${RELEASE_SHA}"
JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".prerelease=${PRERELEASE}")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".body=\"${RELBODY}\"")
RELEASE_DATA=$(curl --data "${JSON_DATA}" -H "Authorization: token ${PERSONAL_TOKEN}" -X POST https://api.github.com/repos/v2fly/V2FlyBleedingEdgeBinary/releases)
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
sleep 1
curl -H "Authorization: token ${PERSONAL_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2fly/V2FlyBleedingEdgeBinary/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
sleep 1
}
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
}
ART_ROOT=${WORKDIR}/bazel-bin/release
pushd ${ART_ROOT}
{
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version ${RELEASE_TAG}
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2flyunstable"
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-macos-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-arm32-v7a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm64-v8a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v7a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v6.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v5.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips64le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips32le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-ppc64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-ppc64le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-riscv64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-s390x.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-freebsd-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-freebsd-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-openbsd-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-openbsd-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-dragonfly-64.zip
} >Release.unsigned.unsorted
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
{
echo "Build Finished"
echo "https://github.com/v2fly/V2FlyBleedingEdgeBinary/releases/tag/${RELEASE_TAG}"
} > buildcomment
go run github.com/v2fly/V2BuildAssist/v2buildutil post commit "${RELEASE_SHA}" < buildcomment
popd
upload ${ART_ROOT}/v2ray-macos-64.zip
upload ${ART_ROOT}/v2ray-windows-64.zip
upload ${ART_ROOT}/v2ray-windows-32.zip
upload ${ART_ROOT}/v2ray-windows-arm32-v7a.zip
upload ${ART_ROOT}/v2ray-linux-64.zip
upload ${ART_ROOT}/v2ray-linux-32.zip
upload ${ART_ROOT}/v2ray-linux-arm64-v8a.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v7a.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v6.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v5.zip
upload ${ART_ROOT}/v2ray-linux-mips64.zip
upload ${ART_ROOT}/v2ray-linux-mips64le.zip
upload ${ART_ROOT}/v2ray-linux-mips32.zip
upload ${ART_ROOT}/v2ray-linux-mips32le.zip
upload ${ART_ROOT}/v2ray-linux-ppc64.zip
upload ${ART_ROOT}/v2ray-linux-ppc64le.zip
upload ${ART_ROOT}/v2ray-linux-riscv64.zip
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
upload ${ART_ROOT}/Release.unsigned

68
release/release.sh Normal file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env bash
ART_ROOT=${WORKDIR}/bazel-bin/release
pushd ${ART_ROOT} || exit 1
# Generate Release.unsigned.unsorted file
{
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version ${RELEASE_TAG}
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
for zip in $(find -L . -type f -name "*.zip"); do
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
done
} >Release.unsigned.unsorted
# Generate Release.unsigned file
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
rm -f Release.unsigned.unsorted
# Test if is bleeding edge release
if [[ "$IsBleedingRelease" == true ]]; then
# If it is a bleeding edge release
# Prepare JSON data, create a release and get release id
RELBODY="https://github.com/${COMMENT_TARGETTED_REPO_OWNER}/${COMMENT_TARGETTED_REPO_NAME}/commit/${RELEASE_SHA}"
JSON_DATA=$(echo "{}" | jq -c ".tag_name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".name=\"${RELEASE_TAG}\"")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".prerelease=${PRERELEASE}")
JSON_DATA=$(echo ${JSON_DATA} | jq -c ".body=\"${RELBODY}\"")
RELEASE_DATA=$(curl -X POST --data "${JSON_DATA}" -H "Authorization: token ${PERSONAL_TOKEN}" "https://api.github.com/repos/${UPLOAD_REPO}/releases")
echo "Bleeding Edge Release data:"
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
# Prepare commit comment message and post it
echo "Build Finished" > buildcomment
echo "https://github.com/${UPLOAD_REPO}/releases/tag/${RELEASE_TAG}" >> buildcomment
go run github.com/v2fly/V2BuildAssist/v2buildutil post commit "${RELEASE_SHA}" < buildcomment
rm -f buildcomment
else
# If is a tag release then get the release id
RELEASE_DATA=$(curl -X GET -H "Authorization: token ${PERSONAL_TOKEN}" "https://api.github.com/repos/${UPLOAD_REPO}/releases/tags/${RELEASE_TAG}")
echo "Tag Release data:"
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
fi
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
curl -H "Authorization: token ${PERSONAL_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/${UPLOAD_REPO}/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
}
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
}
# Upload all files to release assets
for asset in $(find -L . -type f -name "*.zip" -or -type f -name "*.unsigned"); do
upload ${asset}
done

View File

@ -1,108 +0,0 @@
#!/usr/bin/env bash
CONST_refs="refs"
TRIGGER_REASON_A=${TRIGGER_REASON:0:${#CONST_refs}}
if [ $TRIGGER_REASON_A != $CONST_refs ]; then
echo "not a tag: $TRIGGER_REASON_A"
exit
fi
CONST_refsB="refs/tags/"
TRIGGER_REASON_B=${TRIGGER_REASON:0:${#CONST_refsB}}
if [ $TRIGGER_REASON_B != $CONST_refsB ]; then
echo "not a tag (B)"
exit
fi
GITHUB_RELEASE_TAG=${TRIGGER_REASON:${#CONST_refsB}:25}
echo ${GITHUB_RELEASE_TAG}
RELEASE_DATA=$(curl -H "Authorization: token ${PERSONAL_TOKEN}" -X GET https://api.github.com/repos/v2fly/v2ray-core/releases/tags/${GITHUB_RELEASE_TAG})
echo $RELEASE_DATA
RELEASE_ID=$(echo $RELEASE_DATA | jq ".id")
echo $RELEASE_ID
function uploadfile() {
FILE=$1
CTYPE=$(file -b --mime-type $FILE)
sleep 1
curl -H "Authorization: token ${PERSONAL_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2fly/v2ray-core/releases/${RELEASE_ID}/assets?name=$(basename $FILE)"
sleep 1
}
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
}
ART_ROOT=${WORKDIR}/bazel-bin/release
pushd ${ART_ROOT}
{
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version "${GITHUB_RELEASE_TAG}"
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-macos-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-windows-arm32-v7a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm64-v8a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v7a.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v6.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-arm32-v5.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips64le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-mips32le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-ppc64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-ppc64le.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-riscv64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-linux-s390x.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-freebsd-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-freebsd-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-openbsd-64.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-openbsd-32.zip
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file v2ray-dragonfly-64.zip
} >Release.unsigned.unsorted
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort <Release.unsigned.unsorted >Release.unsigned
popd
upload ${ART_ROOT}/v2ray-macos-64.zip
upload ${ART_ROOT}/v2ray-windows-64.zip
upload ${ART_ROOT}/v2ray-windows-32.zip
upload ${ART_ROOT}/v2ray-windows-arm32-v7a.zip
upload ${ART_ROOT}/v2ray-linux-64.zip
upload ${ART_ROOT}/v2ray-linux-32.zip
upload ${ART_ROOT}/v2ray-linux-arm64-v8a.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v7a.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v6.zip
upload ${ART_ROOT}/v2ray-linux-arm32-v5.zip
upload ${ART_ROOT}/v2ray-linux-mips64.zip
upload ${ART_ROOT}/v2ray-linux-mips64le.zip
upload ${ART_ROOT}/v2ray-linux-mips32.zip
upload ${ART_ROOT}/v2ray-linux-mips32le.zip
upload ${ART_ROOT}/v2ray-linux-ppc64.zip
upload ${ART_ROOT}/v2ray-linux-ppc64le.zip
upload ${ART_ROOT}/v2ray-linux-riscv64.zip
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
upload ${ART_ROOT}/Release.unsigned