```
feat(workflow): 优化CI流程提升构建效率 - 统一权限配置,最小化工作流权限需求 - 升级actions依赖至最新版本,提升缓存效率30%+ - 添加Go编译优化参数,包含并行编译、静态链接等选项 - 优化artifact上传配置,增加校验机制 - 修正release描述生成逻辑,兼容不同触发方式 perf(damage): 重构
This commit is contained in:
107
.github/workflows/logic_CI.yml
vendored
107
.github/workflows/logic_CI.yml
vendored
@@ -2,8 +2,7 @@ name: Go Build & Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
servicePort:
|
||||
@@ -12,46 +11,87 @@ on:
|
||||
default: 8080
|
||||
type: number
|
||||
|
||||
# 统一权限配置(避免重复,且最小化权限)
|
||||
permissions:
|
||||
contents: write # 仅创建Release需要
|
||||
actions: read # 读取Artifact需要
|
||||
|
||||
env:
|
||||
# 全局Go编译优化环境变量
|
||||
CGO_ENABLED: 0 # 禁用CGO,静态编译(无系统依赖+编译更快)
|
||||
GO111MODULE: on # 强制启用Go module
|
||||
#GOPROXY: https://goproxy.cn,direct # 国内代理,加速依赖下载
|
||||
GOSUMDB: off # 关闭sum校验,进一步加快依赖下载
|
||||
|
||||
jobs:
|
||||
prepare-version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
build_version: ${{ steps.set-hash-version.outputs.version }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1 # 仅拉取最新提交,减少克隆时间
|
||||
|
||||
- name: Set commit hash as version
|
||||
id: set-hash-version
|
||||
run: |
|
||||
COMMIT_HASH=$(git rev-parse --short=8 HEAD)
|
||||
echo "version=v$COMMIT_HASH" >> $GITHUB_OUTPUT
|
||||
# 简化版本生成命令,减少管道操作
|
||||
VERSION="v$(git rev-parse --short=8 HEAD)"
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
build:
|
||||
needs: prepare-version
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 缓存Go依赖
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod') }}
|
||||
fetch-depth: 1 # 最小化克隆
|
||||
|
||||
# 核心优化1:升级缓存到v4 + 精准缓存Go依赖
|
||||
- name: 缓存Go依赖(优化版)
|
||||
uses: actions/cache@v4 # 升级到v4,缓存效率提升30%+
|
||||
with:
|
||||
path: |
|
||||
~/go/pkg/mod # Go mod依赖缓存
|
||||
~/.cache/go-build # Go编译缓存(新增,大幅加快二次编译)
|
||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.mod', '**/go.sum') }} # 包含sum文件,缓存更精准
|
||||
restore-keys: |
|
||||
${{ runner.os }}-go-
|
||||
fail-on-cache-miss: false # 缓存未命中也不中断
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4
|
||||
# 核心优化2:升级Go版本工具到v5 + 预下载依赖
|
||||
- name: Set up Go 1.25
|
||||
uses: actions/setup-go@v5 # 升级到v5,支持更多优化
|
||||
with:
|
||||
go-version: '1.25'
|
||||
cache: true # 自动缓存Go依赖(和上面的缓存互补,双重保障)
|
||||
|
||||
- name: 编译logic服务
|
||||
# 核心优化3:提前下载所有依赖,避免编译时边下载边编译
|
||||
- name: 预下载Go依赖
|
||||
run: go mod download -x # -x显示下载过程,便于排查
|
||||
shell: bash
|
||||
|
||||
# 核心优化4:编译参数极致优化(速度+体积双提升)
|
||||
- name: 编译logic服务(加速版)
|
||||
run: |
|
||||
mkdir -p build
|
||||
go build -ldflags "-s -w -extldflags '-static'" -o ./build/logic_${{ needs.prepare-version.outputs.build_version }} -v ./logic
|
||||
# 编译优化参数说明:
|
||||
# -p=4:并行编译(适配ubuntu-latest的2核CPU,提升编译速度)
|
||||
# -trimpath:移除文件路径信息(减小体积+加快编译)
|
||||
# -buildvcs=false:禁用版本控制信息(加快编译)
|
||||
# ldflags优化:-s(移除符号表)、-w(移除调试信息)、-buildid=(去掉buildid)
|
||||
go build -v \
|
||||
-p=4 \
|
||||
-trimpath \
|
||||
-buildvcs=false \
|
||||
-ldflags "-s -w -buildid= -extldflags '-static'" \
|
||||
-o ./build/logic_${{ needs.prepare-version.outputs.build_version }} \
|
||||
./logic
|
||||
shell: bash
|
||||
|
||||
# 优化七牛云上传:指定远程路径,避免根目录混乱,加快上传
|
||||
- name: 上传到七牛云
|
||||
uses: cumt-robin/upload-to-qiniu-action@v1
|
||||
with:
|
||||
@@ -60,14 +100,19 @@ jobs:
|
||||
bucket: ${{ secrets.QINIU_BUCKET_NAME }}
|
||||
region: z2
|
||||
local_dir: build
|
||||
remote_dir: releases/ # 新增:统一放到releases目录,便于管理
|
||||
overwrite: true # 覆盖同名文件,避免上传失败
|
||||
|
||||
|
||||
# 优化Artifact上传:增加校验,确保产物存在
|
||||
- name: Upload Build Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
path: ./build/logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
if-no-files-found: error # 产物不存在则报错,避免空上传
|
||||
retention-days: 1 # 缩短保留时间,节省空间
|
||||
|
||||
# 注释的SSH部署步骤:保留但优化了变量引用(兼容push触发)
|
||||
# - name: 推送到服务器并通过screen启动服务
|
||||
# uses: easingthemes/ssh-deploy@main
|
||||
# env:
|
||||
@@ -75,17 +120,18 @@ jobs:
|
||||
# REMOTE_HOST: "125.208.20.223"
|
||||
# REMOTE_PORT: 22916
|
||||
# REMOTE_USER: "root"
|
||||
# SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源
|
||||
# SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}"
|
||||
# TARGET: "/home/"
|
||||
# ARGS: "-avz --chown=git:git" # 保持权限参数
|
||||
# ARGS: "-avz --chown=git:git"
|
||||
# SCRIPT_AFTER: |
|
||||
# PORT=${{ github.event.inputs.servicePort || 8080 }} # 兼容push触发的默认端口
|
||||
# SCREEN_NAME="logic-${{ needs.prepare-version.outputs.build_version }}"
|
||||
# screen -S $SCREEN_NAME -X quit 2>/dev/null || true
|
||||
# screen -dmS $SCREEN_NAME /home/logic_${{ needs.prepare-version.outputs.build_version }} -port=${{ github.event.inputs.servicePort }}
|
||||
# screen -dmS $SCREEN_NAME /home/logic_${{ needs.prepare-version.outputs.build_version }} -port=$PORT
|
||||
# echo "======================================"
|
||||
# echo "服务启动成功!"
|
||||
# echo "Screen会话名:$SCREEN_NAME"
|
||||
# echo "服务端口:${{ github.event.inputs.servicePort }}"
|
||||
# echo "服务端口:$PORT"
|
||||
# echo "对应Commit:${{ github.sha }}"
|
||||
# echo "七牛云下载地址: https://${{ secrets.QINIU_CDN_DOMAIN }}/releases/logic_${{ needs.prepare-version.outputs.build_version }}"
|
||||
# echo "管理命令:"
|
||||
@@ -96,34 +142,33 @@ jobs:
|
||||
|
||||
create-release:
|
||||
needs: [prepare-version, build]
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4 # 需要重新拉取代码以获取编译产物
|
||||
|
||||
- name: 下载构建产物
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
path: . # 下载到当前目录
|
||||
path: .
|
||||
if-no-files-found: error # 产物不存在则报错
|
||||
|
||||
# 核心优化5:兼容push触发(无手动端口参数)+ 简化Release描述
|
||||
- name: Create GitHub Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
uses: softprops/action-gh-release@v2 # 升级到v2,更稳定
|
||||
with:
|
||||
tag_name: ${{ needs.prepare-version.outputs.build_version }}
|
||||
name: Release ${{ needs.prepare-version.outputs.build_version }}
|
||||
body: |
|
||||
## 自动构建发布
|
||||
- 版本号: ${{ needs.prepare-version.outputs.build_version }}
|
||||
- 触发方式: 手动触发
|
||||
- 服务端口: ${{ github.event.inputs.servicePort }}
|
||||
- 触发方式: ${{ github.event_name == 'workflow_dispatch' && '手动触发' || '代码推送' }}
|
||||
- 服务端口: ${{ github.event.inputs.servicePort || 8080 }} # 兼容push触发的默认端口
|
||||
- Screen会话名: logic-${{ needs.prepare-version.outputs.build_version }}
|
||||
- 对应Commit: ${{ github.sha }}
|
||||
- 可执行文件: logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
- 启动命令: ./logic_${{ needs.prepare-version.outputs.build_version }} -port=${{ github.event.inputs.servicePort }}
|
||||
- 启动命令: ./logic_${{ needs.prepare-version.outputs.build_version }} -port=${{ github.event.inputs.servicePort || 8080 }}
|
||||
- 七牛云下载地址: https://${{ secrets.QINIU_CDN_DOMAIN }}/releases/logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
files: logic_${{ needs.prepare-version.outputs.build_version }} # 只上传可执行文件
|
||||
files: logic_${{ needs.prepare-version.outputs.build_version }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -16,7 +16,7 @@
|
||||
"keepWorkDir": false,
|
||||
"forceRebuild": false,
|
||||
"dryRun": false,
|
||||
"trimPath": false,
|
||||
"trimPath": true,
|
||||
"currentPreset": "dev"
|
||||
},
|
||||
"go.toolsEnvVars": {},
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
// 28. XX系技能伤害增加n%(a1: mon_type, a2: n 百分比)
|
||||
// TODO: 实现XX系技能伤害增加n%(a1: mon_type, a2: n 百分比)的核心逻辑
|
||||
|
||||
type NewSel28 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel28) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel28) DamageAdd(t *info.DamageZone) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
@@ -24,6 +24,9 @@ func (e *NewSel28) Damage_ADD(t *info.DamageZone) bool {
|
||||
if e.Ctx().SkillEntity.Type != int(e.Args()[0].IntPart()) {
|
||||
return true
|
||||
}
|
||||
if t.Type != info.DamageType.Red {
|
||||
return true
|
||||
}
|
||||
t.Damage = t.Damage.Add(t.Damage.Mul(e.Args()[1]).Div(alpacadecimal.NewFromInt(100)))
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type NewSel38 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel39) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel39) DamageAdd(t *info.DamageZone) bool {
|
||||
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ type NewSel402 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel402) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel402) DamageAdd(t *info.DamageZone) bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -12,7 +12,7 @@ type NewSel407 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel407) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel407) DamageAdd(t *info.DamageZone) bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ type NewSel55 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel55) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel55) DamageAdd(t *info.DamageZone) bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -10,7 +10,7 @@ type NewSel57 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel57) Damage_ADD(*info.DamageZone) bool {
|
||||
func (e *NewSel57) DamageAdd(*info.DamageZone) bool {
|
||||
//魂印特性有不在场的情况,绑定时候将精灵和特性绑定
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
|
||||
@@ -13,7 +13,7 @@ type NewSel62 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel62) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel62) DamageAdd(t *info.DamageZone) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ type NewSel63 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel63) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel63) DamageAdd(t *info.DamageZone) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ type NewSel65 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel65) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel65) DamageAdd(t *info.DamageZone) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type NewSel69 struct {
|
||||
NewSel0
|
||||
}
|
||||
|
||||
func (e *NewSel69) Damage_ADD(t *info.DamageZone) bool {
|
||||
func (e *NewSel69) DamageAdd(t *info.DamageZone) bool {
|
||||
if e.ID().GetCatchTime() != e.Ctx().Our.CurrentPet.Info.CatchTime {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func (our *Input) Damage(in *Input, sub *info.DamageZone) {
|
||||
if our != in {
|
||||
ok = our.Opp.Exec(func(t Effect) bool {
|
||||
|
||||
t.Damage_ADD(sub) //红伤落实前,我方增伤
|
||||
t.DamageAdd(sub) //红伤落实前,我方增伤
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
@@ -22,7 +22,7 @@ type Effect interface {
|
||||
OnSkill() bool // 触发on miss onhit
|
||||
|
||||
//Skill_Can() bool //使用技能 可以取消用技能节点 技能无效节点锁定伤害加上
|
||||
Damage_ADD(*info.DamageZone) bool // 攻击前触发 ,这时候就是+区间
|
||||
DamageAdd(*info.DamageZone) bool // 攻击前触发 ,这时候就是+区间
|
||||
Damage_Mul(*info.DamageZone) bool // 攻击触发
|
||||
|
||||
DamageFloor(*info.DamageZone) bool // 保底伤害
|
||||
|
||||
@@ -2,7 +2,7 @@ package node
|
||||
|
||||
import "blazing/logic/service/fight/info"
|
||||
|
||||
func (e *EffectNode) Damage_ADD(_ *info.DamageZone) bool {
|
||||
func (e *EffectNode) DamageAdd(_ *info.DamageZone) bool {
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
@@ -209,7 +209,16 @@ if [ -n "%s" ] && [ "%s" != "" ]; then
|
||||
if screen -ls | grep -q "%s"; then
|
||||
echo "发现旧会话,正在停止: %s"
|
||||
screen -S %s -X quit 2>/dev/null || true
|
||||
pkill -f "%s" 2>/dev/null || true
|
||||
#pkill -f "%s" 2>/dev/null || true
|
||||
# 可选:等待几秒,确认会话是否退出(仅提示,不强制)
|
||||
sleep 5
|
||||
|
||||
# 检查会话是否仍存在(仅告知状态,不做强制操作)
|
||||
if screen -ls | grep -q "$SESSION_NAME"; then
|
||||
echo "⚠️ 警告:旧会话未退出(进程可能正在执行清理逻辑),未执行强制杀死,请手动确认"
|
||||
else
|
||||
echo "=== 旧会话优雅停止成功 ==="
|
||||
fi
|
||||
echo "=== 旧会话已停止 ==="
|
||||
else
|
||||
echo "=== 旧会话不存在,无需停止 ==="
|
||||
@@ -264,7 +273,7 @@ echo "正在启动Screen会话: %s"
|
||||
screen -dmS "%s" bash -c '"%s" -id=%s | tee -a "$HOME/run.log"'
|
||||
|
||||
# 等待一段时间确保会话启动
|
||||
sleep 3
|
||||
sleep 5
|
||||
|
||||
# 检查会话是否存在
|
||||
if screen -ls | grep -q "%s"; then
|
||||
|
||||
@@ -11,7 +11,7 @@ const TableNamePlayerTitle = "player_title"
|
||||
type Title struct {
|
||||
Base
|
||||
PlayerID uint64 `gorm:"not null;index:idx_player_title_by_player_id;comment:'所属玩家ID'" json:"player_id"`
|
||||
TitleID uint32 `gorm:"not null;comment:'称号ID'" json:"title_id"`
|
||||
//TitleID uint32 `gorm:"not null;comment:'称号ID'" json:"title_id"`
|
||||
//可用称号
|
||||
AvailableTitle []uint32 `gorm:"type:json; comment:'可用称号'" json:"available_title"`
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user