This commit is contained in:
xinian
2026-01-28 00:55:05 +08:00
parent 2375de2daa
commit 2bcad5d101

View File

@@ -17,7 +17,6 @@ main:
# ========== 生成版本号作为前置步骤 ==========
- name: set version
image: golang:1.23
cpus: 1
commands:
- VERSION="v$(git rev-parse --short=8 HEAD 2>/dev/null || echo "unknown")"
- mkdir -p .build-info
@@ -29,7 +28,7 @@ main:
# ========== 缓存Go依赖 ==========
- name: cache go modules
image: meltwater/drone-cache:latest
cpus: 1
settings:
restore: true
mount:
@@ -42,7 +41,7 @@ main:
# ========== 编译Logic和Login服务 ==========
- name: build
image: golang:1.25
cpus: 1
environment:
CGO_ENABLED: 0
GO111MODULE: on
@@ -53,7 +52,7 @@ main:
# 编译Logic服务
BIN_NAME="logic_${BUILD_VERSION}"
go mod download -x
go build -v -p=1 -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} ./logic
go build -v -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} ./logic
chmod +x ./build/${BIN_NAME}
ls -lh ./build/${BIN_NAME}
file ./build/${BIN_NAME}
@@ -62,7 +61,7 @@ main:
cd login
BIN_NAME="login_${BUILD_VERSION}"
go mod download -x
go build -v -p=1 -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} .
go build -v -trimpath -buildvcs=false -ldflags "-s -w -buildid= -extldflags '-static'" -o ./build/${BIN_NAME} .
chmod +x ./build/${BIN_NAME}
ls -lh ./build/${BIN_NAME}
mv ./build/${BIN_NAME} ../build/
@@ -75,7 +74,6 @@ main:
# ========== 重建缓存 ==========
- name: rebuild cache
image: meltwater/drone-cache:latest
cpus: 1
settings:
rebuild: true
mount:
@@ -88,7 +86,6 @@ main:
# ========== SCP推送Login和Logic到指定服务器 ==========
- name: deploy to login server
image: appleboy/drone-scp:1.6.2
cpus: 1
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
settings:
host: ${LOGIN_SERVER_HOST}
@@ -106,7 +103,6 @@ main:
# ========== SSH启动Login服务并上传Logic到Public ==========
- name: start login and move logic
image: appleboy/drone-ssh:1.6.2
cpus: 1
imports: https://cnb.cool/blzing/key/-/blob/main/githubkey.yml
settings:
host: ${LOGIN_SERVER_HOST}
@@ -128,8 +124,9 @@ main:
session_name="login"
session=$(screen -ls 2>/dev/null | grep -o "[0-9]*\.${session_name}" || true)
if [[ ! -z "$session" ]]; then
screen -X -S "$session_name" stuff "^C"
expect -c "exec screen -x ${session_name}; wait; exit" 2>/dev/null || true
screen -X -S "$session_name" quit 2>/dev/null || true
sleep 1
echo "Info: Stopped login app."
fi
- sleep 1