Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: 持续集成

on:
push:
Expand All @@ -8,7 +8,7 @@ on:

jobs:
ci:
name: Lint & Test & Build
name: 检查、测试和构建
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand All @@ -17,8 +17,18 @@ jobs:
with:
go-version-file: go.mod

- name: Install golangci-lint
- uses: actions/setup-node@v6
with:
node-version: 22
cache: npm
cache-dependency-path: theme/package-lock.json

- name: 安装主题包依赖
working-directory: theme
run: npm ci

- name: 安装 golangci-lint
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest

- name: Run CI checks
- name: 运行 CI 检查
run: make ci
41 changes: 41 additions & 0 deletions .github/workflows/publish-theme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 发布 npm 公共包

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: read

jobs:
publish:
name: 发布 @doudou-start/airgate-theme
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org
cache: npm
cache-dependency-path: theme/package-lock.json

- name: 安装依赖
working-directory: theme
run: npm ci

- name: 构建包
working-directory: theme
run: npm run build

- name: 检查包内容
working-directory: theme
run: npm pack --dry-run

- name: 发布包
working-directory: theme
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ coverage.out
# 本地工具链
.tools/

# 前端依赖和构建产物
frontend/node_modules/
frontend/dist/
# 主题包依赖
theme/node_modules/
28 changes: 21 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ PROTOC_GEN_GRPC_VER := v1.6.0
TOOLS_DIR := $(CURDIR)/.tools
PROTOC_BIN := $(TOOLS_DIR)/bin/protoc

.PHONY: help ci pre-commit lint fmt test vet build proto proto-tools clean setup-hooks
.PHONY: help ci pre-commit lint fmt test vet build theme-package-build theme-package-check theme theme-check proto proto-check proto-tools clean setup-hooks

help: ## 显示帮助信息
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'

# ===================== 质量检查 =====================

ci: lint test vet build ## 本地运行与 CI 完全一致的检查
ci: lint test vet build proto-check theme-package-check theme-check ## 本地运行与 CI 完全一致的检查

pre-commit: lint vet build ## pre-commit hook 调用(跳过耗时的 race 测试)

Expand Down Expand Up @@ -49,11 +49,17 @@ vet: ## 静态分析
build: ## 编译检查
$(GO) build ./...

# ===================== 前端主题 =====================
# ===================== 主题包 =====================

theme: ## 构建前端主题包并生成 DevServer 用 theme.css
cd frontend && npm run build
node --input-type=module -e "import{generateThemeCSS}from'./frontend/dist/css.js';process.stdout.write(generateThemeCSS())" > devserver/static/theme.css
theme-package-build: ## 构建 AirGate 主题包
cd theme && npm run build

theme-package-check: theme-package-build ## 校验 AirGate 主题包构建产物无漂移
@git diff --exit-code -- theme/dist
@echo "AirGate 主题包构建产物无漂移"

theme: theme-package-build ## 构建 AirGate 主题包并生成 DevServer 用 theme.css
node --input-type=module -e "import{generateThemeCSS}from'./theme/dist/css.js';process.stdout.write(generateThemeCSS() + '\n')" > devkit/devserver/static/theme.css
@echo "theme.css 已生成"

# ===================== 代码生成 =====================
Expand All @@ -79,12 +85,20 @@ proto-tools: ## 安装指定版本的 protoc 和 Go 插件
@echo "protoc-gen-go / protoc-gen-go-grpc 已就绪"

proto: proto-tools ## 重新生成 protobuf 代码
@cd proto && PATH=$(TOOLS_DIR)/bin:$$PATH $(PROTOC_BIN) \
@cd protocol/proto && PATH=$(TOOLS_DIR)/bin:$$PATH $(PROTOC_BIN) \
--go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
plugin.proto
@echo "Proto 代码生成完成"

proto-check: proto ## 校验 protobuf 生成代码无漂移
@git diff --exit-code -- protocol/proto/plugin.pb.go protocol/proto/plugin_grpc.pb.go protocol/proto/plugin.proto
@echo "Proto 代码无漂移"

theme-check: theme ## 校验 DevServer 主题 CSS 无漂移
@git diff --exit-code -- devkit/devserver/static/theme.css
@echo "theme.css 无漂移"

# ===================== Git Hooks =====================

setup-hooks: ## 安装 Git pre-commit hook
Expand Down
Loading