Add Go code analyzer workflow
Some checks are pending
Release 3X-UI / Analyze Go code (push) Waiting to run
Release 3X-UI / build (386) (push) Blocked by required conditions
Release 3X-UI / build (amd64) (push) Blocked by required conditions
Release 3X-UI / build (arm64) (push) Blocked by required conditions
Release 3X-UI / build (armv5) (push) Blocked by required conditions
Release 3X-UI / build (armv6) (push) Blocked by required conditions
Release 3X-UI / build (armv7) (push) Blocked by required conditions
Release 3X-UI / build (s390x) (push) Blocked by required conditions
Release 3X-UI / Build for Windows (push) Blocked by required conditions

This commit is contained in:
MHSanaei 2026-03-17 22:30:05 +01:00
parent 554981d9d3
commit f0f98c7122
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
3 changed files with 51 additions and 17 deletions

View file

@ -2,11 +2,9 @@ name: Release 3X-UI
on: on:
workflow_dispatch: workflow_dispatch:
release:
types: [published]
push: push:
branches: branches:
- main - '**'
tags: tags:
- "v*.*.*" - "v*.*.*"
paths: paths:
@ -20,9 +18,48 @@ on:
- 'x-ui.service.debian' - 'x-ui.service.debian'
- 'x-ui.service.arch' - 'x-ui.service.arch'
- 'x-ui.service.rhel' - 'x-ui.service.rhel'
pull_request:
jobs: jobs:
analyze:
name: Analyze Go code
permissions:
contents: read
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Check formatting
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
echo "These files are not gofmt-formatted:"
echo "$unformatted"
exit 1
fi
- name: Run go vet
run: go vet ./...
- name: Run staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: "latest"
install-go: false
- name: Run tests
run: go test -race -shuffle=on ./...
build: build:
needs: analyze
permissions: permissions:
contents: write contents: write
strategy: strategy:
@ -140,12 +177,10 @@ jobs:
- name: Upload files to GH release - name: Upload files to GH release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
if: | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} tag: ${{ github.ref_name }}
file: x-ui-linux-${{ matrix.platform }}.tar.gz file: x-ui-linux-${{ matrix.platform }}.tar.gz
asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz asset_name: x-ui-linux-${{ matrix.platform }}.tar.gz
overwrite: true overwrite: true
@ -156,6 +191,7 @@ jobs:
# ================================= # =================================
build-windows: build-windows:
name: Build for Windows name: Build for Windows
needs: analyze
permissions: permissions:
contents: write contents: write
strategy: strategy:
@ -237,12 +273,10 @@ jobs:
- name: Upload files to GH release - name: Upload files to GH release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
if: | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/'))
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }} tag: ${{ github.ref_name }}
file: x-ui-windows-amd64.zip file: x-ui-windows-amd64.zip
asset_name: x-ui-windows-amd64.zip asset_name: x-ui-windows-amd64.zip
overwrite: true overwrite: true

View file

@ -1,10 +1,10 @@
package controller package controller
import ( import (
"fmt"
"net/http" "net/http"
"text/template" "text/template"
"time" "time"
"fmt"
"github.com/mhsanaei/3x-ui/v2/logger" "github.com/mhsanaei/3x-ui/v2/logger"
"github.com/mhsanaei/3x-ui/v2/web/service" "github.com/mhsanaei/3x-ui/v2/web/service"