diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ef946d..b0f7aed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: push: branches: [main, master, dev] + tags: ["v*"] pull_request: branches: [main, master] @@ -23,7 +24,7 @@ jobs: cache: true - name: Run tests - run: go test -v -race -count=1 ./internal/... + run: make test build: name: Build @@ -46,16 +47,12 @@ jobs: cache: true - name: Build - env: - GOOS: ${{ matrix.goos }} - GOARCH: ${{ matrix.goarch }} - CGO_ENABLED: 0 run: | - VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") - COMMIT=$(git rev-parse --short HEAD) - BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) - LDFLAGS="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.buildDate=${BUILD_DATE}" - go build -ldflags "${LDFLAGS}" -tags "with_clash_api,with_quic" -o xboard-node-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/xboard-node + if [ "${{ matrix.goarch }}" = "amd64" ]; then + make build-linux + else + make build-linux-arm64 + fi - name: Upload Artifact uses: actions/upload-artifact@v4 @@ -105,12 +102,14 @@ jobs: - uses: actions/checkout@v4 - name: Download all artifacts uses: actions/download-artifact@v4 + with: + merge-multiple: true - name: Release uses: softprops/action-gh-release@v2 with: files: | - xboard-node-linux-amd64/xboard-node-linux-amd64 - xboard-node-linux-arm64/xboard-node-linux-arm64 + xboard-node-linux-amd64 + xboard-node-linux-arm64 draft: false prerelease: false env: diff --git a/Makefile b/Makefile index e839426..7b3f828 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) -LDFLAGS := -s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME) +LDFLAGS := -s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown) .PHONY: build clean test docker install @@ -10,18 +10,18 @@ build: # Build for Linux amd64 build-linux: - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -tags "with_quic with_utls with_wireguard with_clash_api" -o xboard-node-linux-amd64 ./cmd/xboard-node + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -tags "with_quic with_utls with_wireguard with_acme with_clash_api" -o xboard-node-linux-amd64 ./cmd/xboard-node # Build for Linux arm64 build-linux-arm64: - CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -tags "with_quic with_utls with_wireguard with_clash_api" -o xboard-node-linux-arm64 ./cmd/xboard-node + CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -tags "with_quic with_utls with_wireguard with_acme with_clash_api" -o xboard-node-linux-arm64 ./cmd/xboard-node # Build all platforms build-all: build-linux build-linux-arm64 # Run tests test: - go test -tags "with_quic with_utls with_wireguard with_clash_api" -v ./... + go test -v -race -count=1 ./internal/... # Clean build artifacts clean: