@@ -2,11 +2,7 @@ name: Release 3X-UI
22
33on :
44 workflow_dispatch :
5- release :
6- types : [published]
75 push :
8- branches :
9- - main
106 tags :
117 - " v*.*.*"
128 paths :
2016 - ' x-ui.service.debian'
2117 - ' x-ui.service.arch'
2218 - ' x-ui.service.rhel'
19+ pull_request :
2320
2421jobs :
22+ analyze :
23+ name : Analyze Go code
24+ permissions :
25+ contents : read
26+ runs-on : ubuntu-latest
27+ timeout-minutes : 20
28+ steps :
29+ - name : Checkout repository
30+ uses : actions/checkout@v6
31+
32+ - name : Set up Go
33+ uses : actions/setup-go@v6
34+ with :
35+ go-version-file : go.mod
36+ cache : true
37+
38+ - name : Check formatting
39+ run : |
40+ unformatted=$(gofmt -l .)
41+ if [ -n "$unformatted" ]; then
42+ echo "These files are not gofmt-formatted:"
43+ echo "$unformatted"
44+ exit 1
45+ fi
46+
47+ - name : Run go vet
48+ run : go vet ./...
49+
50+ - name : Run staticcheck
51+ uses : dominikh/staticcheck-action@v1
52+ with :
53+ version : " latest"
54+ install-go : false
55+
56+ - name : Run tests
57+ run : go test -race -shuffle=on ./...
58+
2559 build :
60+ needs : analyze
2661 permissions :
2762 contents : write
2863 strategy :
@@ -140,12 +175,10 @@ jobs:
140175
141176 - name : Upload files to GH release
142177 uses : svenstaro/upload-release-action@v2
143- if : |
144- (github.event_name == 'release' && github.event.action == 'published') ||
145- (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
178+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
146179 with :
147180 repo_token : ${{ secrets.GITHUB_TOKEN }}
148- tag : ${{ github.ref }}
181+ tag : ${{ github.ref_name }}
149182 file : x-ui-linux-${{ matrix.platform }}.tar.gz
150183 asset_name : x-ui-linux-${{ matrix.platform }}.tar.gz
151184 overwrite : true
@@ -156,6 +189,7 @@ jobs:
156189 # =================================
157190 build-windows :
158191 name : Build for Windows
192+ needs : analyze
159193 permissions :
160194 contents : write
161195 strategy :
@@ -237,12 +271,10 @@ jobs:
237271
238272 - name : Upload files to GH release
239273 uses : svenstaro/upload-release-action@v2
240- if : |
241- (github.event_name == 'release' && github.event.action == 'published') ||
242- (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
274+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
243275 with :
244276 repo_token : ${{ secrets.GITHUB_TOKEN }}
245- tag : ${{ github.ref }}
277+ tag : ${{ github.ref_name }}
246278 file : x-ui-windows-amd64.zip
247279 asset_name : x-ui-windows-amd64.zip
248280 overwrite : true
0 commit comments