-
-
Notifications
You must be signed in to change notification settings - Fork 20
119 lines (117 loc) · 4.36 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Test and Release
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
pull_request:
types: [ opened, synchronize, reopened ]
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- ".github/workflows/*.yml"
release:
types: [ published ]
jobs:
build:
strategy:
matrix:
build-tag: [ 'none' ]
goos: [ linux ]
goarch: [ amd64 ]
goamd64: [ v1, v3 ]
include:
- build-tag: none
goos: linux
goarch: arm64
- build-tag: none
goos: linux
goarch: riscv64
fail-fast: false
runs-on: ubuntu-latest
env:
BUILD_TAG: ${{ matrix.build-tag }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOAMD64: ${{ matrix.goamd64 }}
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate build information
id: get_filename
run: |
echo "BUILD_TAG: $BUILD_TAG, GOOS: $GOOS, GOARCH: $GOARCH, GOAMD64: $GOAMD64"
if [ "$GOAMD64" == "v3" ]; then
if [ "$BUILD_TAG" == "none" ]; then
echo "ASSET_NAME=$GOOS-$GOARCH$GOAMD64" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$GOOS-$GOARCH$GOAMD64" >> $GITHUB_ENV
else
echo "ASSET_NAME=$GOOS-$GOARCH$GOAMD64-$BUILD_TAG" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$GOOS-$GOARCH$GOAMD64-$BUILD_TAG" >> $GITHUB_ENV
fi
else
if [ "$BUILD_TAG" == "none" ]; then
echo "ASSET_NAME=$GOOS-$GOARCH" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$GOOS-$GOARCH" >> $GITHUB_ENV
else
echo "ASSET_NAME=$GOOS-$GOARCH-$BUILD_TAG" >> $GITHUB_OUTPUT
echo "ASSET_NAME=$GOOS-$GOARCH-$BUILD_TAG" >> $GITHUB_ENV
fi
fi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ^1.23
- name: Get project dependencies
run: go mod download
- name: Build next-server
run: |
mkdir -p build_assets
if [ $BUILD_TAG != "none" ]; then
go build -v -o build_assets/next-server -trimpath -ldflags "-s -w -buildid=" -tags $BUILD_TAG
else
go build -v -o build_assets/next-server -trimpath -ldflags "-s -w -buildid="
fi
- name: Prepare config files
run: |
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
cp ${GITHUB_WORKSPACE}/release/config/dns.json ./build_assets/dns.json
cp ${GITHUB_WORKSPACE}/release/config/route.json ./build_assets/route.json
cp ${GITHUB_WORKSPACE}/release/config/custom_outbound.json ./build_assets/custom_outbound.json
cp ${GITHUB_WORKSPACE}/release/config/custom_inbound.json ./build_assets/custom_inbound.json
cp ${GITHUB_WORKSPACE}/release/config/rulelist ./build_assets/rulelist
cp ${GITHUB_WORKSPACE}/release/config/config.yml.example ./build_assets/config.yml
wget -O ./build_assets/geoip.dat https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat
wget -O ./build_assets/geosite.dat https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat
- name: Create zip archive
run: |
pushd build_assets || exit 1
zip -9vr ../next-server-$ASSET_NAME.zip .
popd || exit 1
FILE=./next-server-$ASSET_NAME.zip
DGST=$FILE.hash.txt
openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >>$DGST
openssl dgst -sha3-256 $FILE | sed 's/([^)]*)//g' >>$DGST
mv build_assets next-server-$ASSET_NAME
- name: Upload files to artifacts
uses: actions/upload-artifact@v4
with:
name: next-server-${{ steps.get_filename.outputs.ASSET_NAME }}
path: |
./next-server-${{ steps.get_filename.outputs.ASSET_NAME }}/*
- name: Upload files to release
uses: svenstaro/upload-release-action@v2
if: ${{ github.event_name == 'release' }}
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./next-server-${{ steps.get_filename.outputs.ASSET_NAME }}.zip*
tag: ${{ github.ref }}
file_glob: true