| 1 |
name: Release |
| 2 |
|
| 3 |
on: |
| 4 |
release: |
| 5 |
types: [prereleased] |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- master |
| 9 |
- v* |
| 10 |
- dev* |
| 11 |
paths: |
| 12 |
- "**/*.go" |
| 13 |
- "go.mod" |
| 14 |
- "go.sum" |
| 15 |
- ".github/workflows/*.yml" |
| 16 |
pull_request: |
| 17 |
types: [opened, synchronize, reopened] |
| 18 |
paths: |
| 19 |
- "**/*.go" |
| 20 |
- "go.mod" |
| 21 |
- "go.sum" |
| 22 |
- ".github/workflows/*.yml" |
| 23 |
|
| 24 |
jobs: |
| 25 |
build: |
| 26 |
if: github.repository != 'v2ray/v2ray-core' |
| 27 |
strategy: |
| 28 |
matrix: |
| 29 |
# Include amd64 on all platforms. |
| 30 |
goos: [windows, freebsd, openbsd, linux, dragonfly, darwin] |
| 31 |
goarch: [amd64, 386] |
| 32 |
exclude: |
| 33 |
# Exclude i386 on darwin and dragonfly. |
| 34 |
- goarch: 386 |
| 35 |
goos: dragonfly |
| 36 |
- goarch: 386 |
| 37 |
goos: darwin |
| 38 |
include: |
| 39 |
# BEGIN Linux ARM 5 6 7 |
| 40 |
- goos: linux |
| 41 |
goarch: arm |
| 42 |
goarm: 7 |
| 43 |
- goos: linux |
| 44 |
goarch: arm |
| 45 |
goarm: 6 |
| 46 |
- goos: linux |
| 47 |
goarch: arm |
| 48 |
goarm: 5 |
| 49 |
# END Linux ARM 5 6 7 |
| 50 |
# Windows ARM 7 |
| 51 |
- goos: windows |
| 52 |
goarch: arm |
| 53 |
goarm: 7 |
| 54 |
# BEGIN Other architectures |
| 55 |
- goos: linux |
| 56 |
goarch: arm64 |
| 57 |
- goos: linux |
| 58 |
goarch: riscv64 |
| 59 |
# BEGIN MIPS |
| 60 |
- goos: linux |
| 61 |
goarch: mips64 |
| 62 |
- goos: linux |
| 63 |
goarch: mips64le |
| 64 |
- goos: linux |
| 65 |
goarch: mipsle |
| 66 |
- goos: linux |
| 67 |
goarch: mips |
| 68 |
# END MIPS |
| 69 |
# BEGIN Android |
| 70 |
- goos: android |
| 71 |
goarch: arm64 |
| 72 |
# END Android |
| 73 |
# END Other architectures |
| 74 |
fail-fast: false |
| 75 |
|
| 76 |
runs-on: ubuntu-latest |
| 77 |
env: |
| 78 |
GOOS: ${{ matrix.goos }} |
| 79 |
GOARCH: ${{ matrix.goarch }} |
| 80 |
GOARM: ${{ matrix.goarm }} |
| 81 |
CGO_ENABLED: 0 |
| 82 |
|
| 83 |
steps: |
| 84 |
- name: Checkout codebase |
| 85 |
uses: actions/checkout@v2 |
| 86 |
with: |
| 87 |
fetch-depth: 0 |
| 88 |
|
| 89 |
- name: Show workflow information |
| 90 |
id: get_filename |
| 91 |
run: | |
| 92 |
export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM\"].friendlyName" -r < release/friendly-filenames.json) |
| 93 |
echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, RELEASE_NAME: $_NAME" |
| 94 |
echo "::set-output name=ASSET_NAME::$_NAME" |
| 95 |
echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV |
| 96 |
|
| 97 |
- name: Set up Go |
| 98 |
uses: actions/setup-go@v2 |
| 99 |
with: |
| 100 |
go-version: 1.15 |
| 101 |
|
| 102 |
- name: Get project dependencies |
| 103 |
run: go mod download |
| 104 |
|
| 105 |
- name: Build V2Ray |
| 106 |
run: | |
| 107 |
mkdir -p build_assets |
| 108 |
go build -v -o build_assets/v2ray -trimpath -ldflags "-s -w -buildid=" ./main |
| 109 |
go build -v -o build_assets/v2ctl -trimpath -ldflags "-s -w -buildid=" -tags confonly ./infra/control/main |
| 110 |
|
| 111 |
- name: Build Windows wv2ray |
| 112 |
if: matrix.goos == 'windows' |
| 113 |
run: | |
| 114 |
echo "::warning ::wv2ray.exe will be removed in v5" |
| 115 |
go build -v -o build_assets/wv2ray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main |
| 116 |
cd ./build_assets || exit 1 |
| 117 |
mv v2ray v2ray.exe |
| 118 |
mv v2ctl v2ctl.exe |
| 119 |
|
| 120 |
- name: Prepare package |
| 121 |
run: cp -v ./release/config/*.* ./build_assets |
| 122 |
|
| 123 |
- name: Prepare package for Linux |
| 124 |
if: matrix.goos == 'linux' |
| 125 |
run: cp -rv ./release/config/systemd ./build_assets/ |
| 126 |
|
| 127 |
- name: Create ZIP archive |
| 128 |
run: | |
| 129 |
pushd build_assets || exit 1 |
| 130 |
zip -9vr ../v2ray-$ASSET_NAME.zip . |
| 131 |
popd || exit 1 |
| 132 |
FILE=./v2ray-$ASSET_NAME.zip |
| 133 |
DGST=$FILE.dgst |
| 134 |
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 135 |
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 136 |
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 137 |
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 138 |
|
| 139 |
- name: Upload ZIP file to Artifacts |
| 140 |
uses: actions/upload-artifact@v2 |
| 141 |
with: |
| 142 |
name: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip |
| 143 |
path: v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip |
| 144 |
|
| 145 |
- name: Upload files to GitHub release |
| 146 |
uses: svenstaro/upload-release-action@v2 |
| 147 |
if: github.event_name == 'release' |
| 148 |
with: |
| 149 |
repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 150 |
file_glob: true |
| 151 |
file: ./v2ray-${{ steps.get_filename.outputs.ASSET_NAME }}.zip* |
| 152 |
tag: ${{ github.ref }} |
| 153 |
|
| 154 |
signature: |
| 155 |
if: github.repository != 'v2ray/v2ray-core' |
| 156 |
runs-on: ubuntu-latest |
| 157 |
needs: build |
| 158 |
steps: |
| 159 |
- name: Checkout codebase |
| 160 |
uses: actions/checkout@v2 |
| 161 |
with: |
| 162 |
fetch-depth: 0 |
| 163 |
|
| 164 |
- name: Set up Go |
| 165 |
uses: actions/setup-go@v2 |
| 166 |
with: |
| 167 |
go-version: 1.15 |
| 168 |
|
| 169 |
- uses: actions/download-artifact@v2 |
| 170 |
with: |
| 171 |
path: build_artifacts |
| 172 |
|
| 173 |
- name: Generate shasum |
| 174 |
run: | |
| 175 |
cd build_artifacts || exit 1 |
| 176 |
mkdir .temp |
| 177 |
mv ./*/*.zip ./.temp |
| 178 |
rmdir ./*/ |
| 179 |
mv ./.temp/* . |
| 180 |
ls -lah --recursive |
| 181 |
{ |
| 182 |
go run github.com/v2fly/V2BuildAssist/v2buildutil gen version $(git describe --tags $(git rev-list --tags --max-count=1)) |
| 183 |
go run github.com/v2fly/V2BuildAssist/v2buildutil gen project "v2fly" |
| 184 |
for zip in $(ls *.zip); do |
| 185 |
go run github.com/v2fly/V2BuildAssist/v2buildutil gen file ${zip} |
| 186 |
done |
| 187 |
} >Release.unsigned.unsorted |
| 188 |
go run github.com/v2fly/V2BuildAssist/v2buildutil gen sort < Release.unsigned.unsorted > Release.unsigned |
| 189 |
rm -f Release.unsigned.unsorted |
| 190 |
FILE=./Release.unsigned |
| 191 |
DGST=$FILE.dgst |
| 192 |
openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 193 |
openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 194 |
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 195 |
openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >>$DGST |
| 196 |
|
| 197 |
- uses: actions/upload-artifact@v2 |
| 198 |
with: |
| 199 |
name: Release.unsigned |
| 200 |
path: build_artifacts/Release.unsigned |
| 201 |
|
| 202 |
- uses: actions/upload-artifact@v2 |
| 203 |
with: |
| 204 |
name: Release.unsigned.dgst |
| 205 |
path: build_artifacts/Release.unsigned.dgst |
| 206 |
|
| 207 |
- name: Upload Release.unsigned related files |
| 208 |
uses: svenstaro/upload-release-action@v2 |
| 209 |
if: github.event_name == 'release' |
| 210 |
with: |
| 211 |
repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 212 |
file_glob: true |
| 213 |
file: build_artifacts/Release.unsigned* |
| 214 |
tag: ${{ github.ref }} |