mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-10-18 01:41:33 -04:00
Use GitHub Actions matrix feature to build and release (#468)
Co-authored-by: loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com>
This commit is contained in:
parent
8cb2db5321
commit
3342afbada
208
.github/workflows/release.yml
vendored
208
.github/workflows/release.yml
vendored
@ -12,66 +12,198 @@ on:
|
|||||||
- "**/*.go"
|
- "**/*.go"
|
||||||
- "go.mod"
|
- "go.mod"
|
||||||
- "go.sum"
|
- "go.sum"
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
paths:
|
paths:
|
||||||
- "**/*.go"
|
- "**/*.go"
|
||||||
- "go.mod"
|
- "go.mod"
|
||||||
- "go.sum"
|
- "go.sum"
|
||||||
|
- ".github/workflows/*.yml"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: github.repository != 'v2ray/v2ray-core'
|
if: github.repository != 'v2ray/v2ray-core'
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
steps:
|
matrix:
|
||||||
- name: Set up Go 1.x
|
# Include amd64 on all platforms.
|
||||||
uses: actions/setup-go@v2
|
goos: [windows, freebsd, openbsd, linux, dragonfly, darwin]
|
||||||
with:
|
goarch: [amd64, 386]
|
||||||
go-version: 1.15
|
exclude:
|
||||||
|
# Exclude i386 on darwin and dragonfly.
|
||||||
|
- goarch: 386
|
||||||
|
goos: dragonfly
|
||||||
|
- goarch: 386
|
||||||
|
goos: darwin
|
||||||
|
include:
|
||||||
|
# BEGIN Linux ARM 5 6 7
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 6
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm
|
||||||
|
goarm: 5
|
||||||
|
# END Linux ARM 5 6 7
|
||||||
|
# Windows ARM 7
|
||||||
|
- goos: windows
|
||||||
|
goarch: arm
|
||||||
|
goarm: 7
|
||||||
|
# BEGIN Other architectures
|
||||||
|
- goos: linux
|
||||||
|
goarch: arm64
|
||||||
|
- goos: linux
|
||||||
|
goarch: riscv64
|
||||||
|
# BEGIN MIPS
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips64le
|
||||||
|
- goos: linux
|
||||||
|
goarch: mipsle
|
||||||
|
- goos: linux
|
||||||
|
goarch: mips
|
||||||
|
# END MIPS
|
||||||
|
# END Other architectures
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GOOS: ${{ matrix.goos }}
|
||||||
|
GOARCH: ${{ matrix.goarch }}
|
||||||
|
GOARM: ${{ matrix.goarm }}
|
||||||
|
CGO_ENABLED: 0
|
||||||
|
|
||||||
|
steps:
|
||||||
- name: Checkout codebase
|
- name: Checkout codebase
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Show workflow information
|
||||||
|
id: get_filename
|
||||||
|
run: |
|
||||||
|
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json)
|
||||||
|
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME"
|
||||||
|
echo "::set-output name=ASSET_NAME::$_NAME"
|
||||||
|
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.15
|
||||||
|
|
||||||
- name: Get project dependencies
|
- name: Get project dependencies
|
||||||
run: go mod download
|
run: go mod download
|
||||||
|
|
||||||
- name: Set variables
|
- name: Build V2Ray
|
||||||
run: |
|
run: |
|
||||||
echo "BleedingReleaseTag=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
|
mkdir -p build_assets
|
||||||
echo "TagReleaseTag=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
|
go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main
|
||||||
shell: bash
|
go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build Windows wv2ray
|
||||||
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
|
if: matrix.goos == 'windows'
|
||||||
|
|
||||||
- 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: |
|
run: |
|
||||||
chmod u+x ./release/release.sh
|
go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main
|
||||||
./release/release.sh
|
cd ./build_assets || exit 1
|
||||||
|
mv v2ray v2ray.exe
|
||||||
|
mv v2ctl v2ctl.exe
|
||||||
|
|
||||||
- name: Upload binaries to current repo
|
- name: Prepare package
|
||||||
|
run: cp -v ./release/config/*.* ./build_assets
|
||||||
|
|
||||||
|
- name: Prepare package for Linux
|
||||||
|
if: matrix.goos == 'linux'
|
||||||
|
run: cp -rv ./release/config/systemd ./build_assets/
|
||||||
|
|
||||||
|
- name: Create ZIP archive
|
||||||
|
run: |
|
||||||
|
pushd build_assets || exit 1
|
||||||
|
zip -9vr ../v2ray-$ASSET_NAME.zip .
|
||||||
|
popd || exit 1
|
||||||
|
FILE=./v2ray-$ASSET_NAME.zip
|
||||||
|
DGST=$FILE.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
|
||||||
|
|
||||||
|
- name: Upload ZIP file to Artifacts
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
|
||||||
|
path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip
|
||||||
|
|
||||||
|
- name: Upload files to GitHub release
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
if: github.event_name == 'release'
|
if: github.event_name == 'release'
|
||||||
env:
|
with:
|
||||||
IsBleedingRelease: false
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
WORKDIR: ${{ github.workspace }}
|
file_glob: true
|
||||||
PRERELEASE: true
|
file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
|
||||||
RELEASE_SHA: ${{ github.sha }}
|
tag: ${{ github.ref }}
|
||||||
RELEASE_TAG: ${{ env.TagReleaseTag }}
|
|
||||||
UPLOAD_REPO: ${{ github.repository }}
|
signature:
|
||||||
PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
if: github.repository != 'v2ray/v2ray-core'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- name: Checkout codebase
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.15
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v2
|
||||||
|
with:
|
||||||
|
path: build_artifacts
|
||||||
|
|
||||||
|
- name: Generate shasum
|
||||||
run: |
|
run: |
|
||||||
chmod u+x ./release/release.sh
|
cd build_artifacts || exit 1
|
||||||
./release/release.sh
|
mkdir .temp
|
||||||
|
mv ./*/*.zip ./.temp
|
||||||
|
rmdir ./*/
|
||||||
|
mv ./.temp/* .
|
||||||
|
ls -lah --recursive
|
||||||
|
{
|
||||||
|
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1))
|
||||||
|
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly"
|
||||||
|
for zip in $(ls *.zip); do
|
||||||
|
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip}
|
||||||
|
done
|
||||||
|
} >Release.unsigned.unsorted
|
||||||
|
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned
|
||||||
|
rm -f Release.unsigned.unsorted
|
||||||
|
FILE=./Release.unsigned
|
||||||
|
DGST=$FILE.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
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Release.unsigned
|
||||||
|
path: build_artifacts/Release.unsigned
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: Release.unsigned.dgst
|
||||||
|
path: build_artifacts/Release.unsigned.dgst
|
||||||
|
|
||||||
|
- name: Upload Release.unsigned related files
|
||||||
|
uses: svenstaro/upload-release-action@v2
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
with:
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
file_glob: true
|
||||||
|
file: build_artifacts/Release.unsigned*
|
||||||
|
tag: ${{ github.ref }}
|
||||||
|
6
.github/workflows/sign.yml
vendored
6
.github/workflows/sign.yml
vendored
@ -14,7 +14,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Grant it execution permission
|
- name: Grant it execution permission
|
||||||
run: |
|
run: |
|
||||||
chmod +x $GITHUB_WORKSPACE/release/requestsign_github.sh
|
|
||||||
chmod +x $GITHUB_WORKSPACE/release/requestsign.sh
|
chmod +x $GITHUB_WORKSPACE/release/requestsign.sh
|
||||||
|
|
||||||
- name: Invoke release signing
|
- name: Invoke release signing
|
||||||
@ -22,4 +21,7 @@ jobs:
|
|||||||
SIGN_SERVICE_PASSWORD: ${{ secrets.SIGN_SERVICE_PASSWORD }}
|
SIGN_SERVICE_PASSWORD: ${{ secrets.SIGN_SERVICE_PASSWORD }}
|
||||||
SIGN_SERIVCE_URL: ${{ secrets.SIGN_SERIVCE_URL }}
|
SIGN_SERIVCE_URL: ${{ secrets.SIGN_SERIVCE_URL }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: $GITHUB_WORKSPACE/release/requestsign_github.sh
|
run: |
|
||||||
|
export SIGN_VERSION=$(cat $GITHUB_EVENT_PATH| jq -r ".release.tag_name")
|
||||||
|
echo $SIGN_VERSION
|
||||||
|
$GITHUB_WORKSPACE/release/requestsign.sh
|
||||||
|
22
release/friendly-filenames.json
Normal file
22
release/friendly-filenames.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"darwin-amd64": { "friendlyName": "macos-64" },
|
||||||
|
"dragonfly-amd64": { "friendlyName": "dragonfly-64" },
|
||||||
|
"freebsd-386": { "friendlyName": "freebsd-32" },
|
||||||
|
"freebsd-amd64": { "friendlyName": "freebsd-64" },
|
||||||
|
"linux-386": { "friendlyName": "linux-32" },
|
||||||
|
"linux-amd64": { "friendlyName": "linux-64" },
|
||||||
|
"linux-arm5": { "friendlyName": "linux-arm32-v5" },
|
||||||
|
"linux-arm64": { "friendlyName": "linux-arm64-v8a" },
|
||||||
|
"linux-arm6": { "friendlyName": "linux-arm32-v6" },
|
||||||
|
"linux-arm7": { "friendlyName": "linux-arm32-v7a" },
|
||||||
|
"linux-mips64le": { "friendlyName": "linux-mips64le" },
|
||||||
|
"linux-mips64": { "friendlyName": "linux-mips64" },
|
||||||
|
"linux-mipsle": { "friendlyName": "linux-mips32le" },
|
||||||
|
"linux-mips": { "friendlyName": "linux-mips32" },
|
||||||
|
"linux-riscv64": { "friendlyName": "linux-riscv64" },
|
||||||
|
"openbsd-386": { "friendlyName": "openbsd-32" },
|
||||||
|
"openbsd-amd64": { "friendlyName": "openbsd-64" },
|
||||||
|
"windows-amd64": { "friendlyName": "windows-64" },
|
||||||
|
"windows-386": { "friendlyName": "windows-32" },
|
||||||
|
"windows-arm7": { "friendlyName": "windows-arm32-v7a" }
|
||||||
|
}
|
@ -1,68 +0,0 @@
|
|||||||
#!/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
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
export SIGN_VERSION=$(cat $GITHUB_EVENT_PATH| jq -r ".release.tag_name")
|
|
||||||
|
|
||||||
echo $SIGN_VERSION
|
|
||||||
|
|
||||||
$GITHUB_WORKSPACE/release/requestsign.sh
|
|
Loading…
Reference in New Issue
Block a user