```
chore(ci): 更新GitHub Actions工作流配置 - 添加push触发器,仅在main分支上自动触发 - 为servicePort输入添加默认值8080 - 将Go版本从1.20升级到1.25 - 添加七牛云上传功能,将构建产物上传到CDN - 注释掉SSH部署到服务器的步骤,改为CDN分发 - 在发布说明中添加七牛云下载链接 chore(vscode): 更新Go构建配置 - 禁用zcli功能 - 启用stripSymbols以减小构建产物体积 - 启用trimPath以优化构建路径 ```
This commit is contained in:
68
.github/workflows/logic_CI.yml
vendored
68
.github/workflows/logic_CI.yml
vendored
@@ -1,11 +1,15 @@
|
|||||||
name: Go Build & Release
|
name: Go Build & Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
servicePort:
|
servicePort:
|
||||||
description: '服务启动端口'
|
description: '服务启动端口'
|
||||||
required: true
|
required: true
|
||||||
|
default: 8080
|
||||||
type: number
|
type: number
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@@ -41,12 +45,24 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v4
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: '1.20'
|
go-version: '1.25'
|
||||||
|
|
||||||
- name: 编译logic服务
|
- name: 编译logic服务
|
||||||
run: go build -o ./logic_${{ needs.prepare-version.outputs.build_version }} -v ./logic
|
run: go build -o ./logic_${{ needs.prepare-version.outputs.build_version }} -v ./logic
|
||||||
# 移除了public目录,直接在当前目录生成可执行文件
|
# 移除了public目录,直接在当前目录生成可执行文件
|
||||||
|
|
||||||
|
- name: 上传到七牛云
|
||||||
|
uses: luochongfei/up2qn@master
|
||||||
|
with:
|
||||||
|
bucket: ${{ secrets.QINIU_BUCKET_NAME }}
|
||||||
|
zone: "z2"
|
||||||
|
access_key: ${{ secrets.QINIU_AK }}
|
||||||
|
secret_key: ${{ secrets.QINIU_SK }}
|
||||||
|
local_dir: .
|
||||||
|
local_exclude: "**/*.go|**/go.mod|**/go.sum"
|
||||||
|
target_dir: releases/
|
||||||
|
target_file: "logic_${{ needs.prepare-version.outputs.build_version }}"
|
||||||
|
|
||||||
- name: Upload Build Artifact
|
- name: Upload Build Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
@@ -54,30 +70,31 @@ jobs:
|
|||||||
path: ./logic_${{ needs.prepare-version.outputs.build_version }}
|
path: ./logic_${{ needs.prepare-version.outputs.build_version }}
|
||||||
# 直接上传可执行文件
|
# 直接上传可执行文件
|
||||||
|
|
||||||
- name: 推送到服务器并通过screen启动服务
|
# - name: 推送到服务器并通过screen启动服务
|
||||||
uses: easingthemes/ssh-deploy@main
|
# uses: easingthemes/ssh-deploy@main
|
||||||
env:
|
# env:
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.BLAZING }}
|
# SSH_PRIVATE_KEY: ${{ secrets.BLAZING }}
|
||||||
REMOTE_HOST: "125.208.20.223"
|
# REMOTE_HOST: "125.208.20.223"
|
||||||
REMOTE_PORT: 22916
|
# REMOTE_PORT: 22916
|
||||||
REMOTE_USER: "root"
|
# REMOTE_USER: "root"
|
||||||
SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源
|
# SOURCE: "logic_${{ needs.prepare-version.outputs.build_version }}" # 只指定可执行文件作为源
|
||||||
TARGET: "/home/"
|
# TARGET: "/home/"
|
||||||
ARGS: "-avz --chown=git:git" # 保持权限参数
|
# ARGS: "-avz --chown=git:git" # 保持权限参数
|
||||||
SCRIPT_AFTER: |
|
# SCRIPT_AFTER: |
|
||||||
SCREEN_NAME="logic-${{ needs.prepare-version.outputs.build_version }}"
|
# SCREEN_NAME="logic-${{ needs.prepare-version.outputs.build_version }}"
|
||||||
screen -S $SCREEN_NAME -X quit 2>/dev/null || true
|
# 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=${{ github.event.inputs.servicePort }}
|
||||||
echo "======================================"
|
# echo "======================================"
|
||||||
echo "服务启动成功!"
|
# echo "服务启动成功!"
|
||||||
echo "Screen会话名:$SCREEN_NAME"
|
# echo "Screen会话名:$SCREEN_NAME"
|
||||||
echo "服务端口:${{ github.event.inputs.servicePort }}"
|
# echo "服务端口:${{ github.event.inputs.servicePort }}"
|
||||||
echo "对应Commit:${{ github.sha }}"
|
# echo "对应Commit:${{ github.sha }}"
|
||||||
echo "管理命令:"
|
# echo "七牛云下载地址: https://${{ secrets.QINIU_CDN_DOMAIN }}/releases/logic_${{ needs.prepare-version.outputs.build_version }}"
|
||||||
echo " - 进入会话:screen -r $SCREEN_NAME"
|
# echo "管理命令:"
|
||||||
echo " - 查看所有会话:screen -ls"
|
# echo " - 进入会话:screen -r $SCREEN_NAME"
|
||||||
echo " - 停止服务:screen -S $SCREEN_NAME -X quit"
|
# echo " - 查看所有会话:screen -ls"
|
||||||
echo "======================================"
|
# echo " - 停止服务:screen -S $SCREEN_NAME -X quit"
|
||||||
|
# echo "======================================"
|
||||||
|
|
||||||
create-release:
|
create-release:
|
||||||
needs: [prepare-version, build]
|
needs: [prepare-version, build]
|
||||||
@@ -108,6 +125,7 @@ jobs:
|
|||||||
- 对应Commit: ${{ github.sha }}
|
- 对应Commit: ${{ github.sha }}
|
||||||
- 可执行文件: logic_${{ needs.prepare-version.outputs.build_version }}
|
- 可执行文件: 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 }}
|
||||||
|
- 七牛云下载地址: 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
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|||||||
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
@@ -2,11 +2,12 @@
|
|||||||
"goBuild.savedBuildConfig": {
|
"goBuild.savedBuildConfig": {
|
||||||
"outputName": "",
|
"outputName": "",
|
||||||
"outputDir": "./public",
|
"outputDir": "./public",
|
||||||
|
"zcliEnabled": false,
|
||||||
"targetOS": "linux",
|
"targetOS": "linux",
|
||||||
"targetArch": "current",
|
"targetArch": "current",
|
||||||
"enableRace": false,
|
"enableRace": false,
|
||||||
"enableOptimization": true,
|
"enableOptimization": true,
|
||||||
"stripSymbols": false,
|
"stripSymbols": true,
|
||||||
"cgoEnabled": false,
|
"cgoEnabled": false,
|
||||||
"buildTags": "",
|
"buildTags": "",
|
||||||
"customLdflags": "",
|
"customLdflags": "",
|
||||||
@@ -15,8 +16,9 @@
|
|||||||
"keepWorkDir": false,
|
"keepWorkDir": false,
|
||||||
"forceRebuild": false,
|
"forceRebuild": false,
|
||||||
"dryRun": false,
|
"dryRun": false,
|
||||||
"trimPath": false,
|
"trimPath": true,
|
||||||
"currentPreset": "dev"
|
"currentPreset": "dev"
|
||||||
},
|
},
|
||||||
"go.toolsEnvVars": {}
|
"go.toolsEnvVars": {},
|
||||||
|
"goBuild.zcli.enabled": false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user