feat(ci): 迁移到 hk runner + Release 产物分发,解除对 doc79 runner 的依赖
- 两个工作流 runs-on 改为 hk(在线);Go/Node 工具链自包含下载+工作区缓存 - 后端产物改为发布 Gitea Release 附件(server-v<版本>),与 runner 位置解耦 - deploy-watch.sh 重写为从 Release 拉取:匿名/令牌 HTTPS 下载、包结构预检、 按 release id 幂等、失败下轮重试 - 移除对 /ci-artifacts 本机目录的依赖(原设计要求 runner 与生产同机) - PULL_DEPLOY.md 架构图同步更新
This commit is contained in:
@@ -11,21 +11,45 @@ on:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
# 专属运行器 lunar-node: docker://node:22-bookworm(注册于 doc79)
|
||||
runs-on: lunar-node
|
||||
# hk runner(海外,宿主机直接执行;可直连微信与 Telegram/Discord)
|
||||
runs-on: hk
|
||||
steps:
|
||||
- uses: https://gitea.neatcn.com/gouki/action-checkout@v4
|
||||
with:
|
||||
# Need recent commit subjects for the WeChat upload remark.
|
||||
fetch-depth: 20
|
||||
|
||||
- name: Prepare Node toolchain
|
||||
run: |
|
||||
# 优先复用 runner 宿主机缓存的工具链(工作目录持久化)
|
||||
TOOLDIR="$RUNNER_WORKSPACE/.lunar-toolchain"
|
||||
mkdir -p "$TOOLDIR"
|
||||
if [ -x "$TOOLDIR/node/bin/node" ]; then
|
||||
echo "复用缓存 Node 工具链"
|
||||
else
|
||||
wget -q --tries=2 --timeout=60 -O "$TOOLDIR/node.tgz" \
|
||||
"https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.xz" \
|
||||
|| wget -q --tries=2 --timeout=60 -O "$TOOLDIR/node.tgz" \
|
||||
"https://mirrors.aliyun.com/nodejs-release/v22.12.0/node-v22.12.0-linux-x64.tar.xz"
|
||||
rm -rf "$TOOLDIR/node-v22.12.0-linux-x64"
|
||||
tar -C "$TOOLDIR" -xJf "$TOOLDIR/node.tgz"
|
||||
mv "$TOOLDIR/node-v22.12.0-linux-x64" "$TOOLDIR/node"
|
||||
rm -f "$TOOLDIR/node.tgz"
|
||||
fi
|
||||
"$TOOLDIR/node/bin/node" --version
|
||||
echo "PATH=$TOOLDIR/node/bin:$PATH" >> "$GITEA_ENV"
|
||||
|
||||
- name: Verify Node runtime
|
||||
run: node --version
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: mini
|
||||
run: npm ci
|
||||
|
||||
- name: Run tests
|
||||
working-directory: mini
|
||||
run: npm test
|
||||
|
||||
- name: Configure production API and app version
|
||||
working-directory: mini
|
||||
env:
|
||||
@@ -39,7 +63,7 @@ jobs:
|
||||
mkdir -p ci-artifacts
|
||||
printf '%s\n' "$VERSION" > ci-artifacts/resolved-version.txt
|
||||
echo "Resolved Mini Program version for build+upload: $VERSION"
|
||||
|
||||
|
||||
# 注入版本号到 utils/version.js
|
||||
BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
COMMIT_SHORT="${GITEA_SHA:0:7}"
|
||||
@@ -48,7 +72,7 @@ jobs:
|
||||
* 版本号配置文件
|
||||
* 此文件由 CI 构建时自动生成,请勿手动修改
|
||||
*/
|
||||
|
||||
|
||||
module.exports = {
|
||||
version: "$VERSION",
|
||||
buildNumber: "$MINIAPP_BUILD_NUMBER",
|
||||
@@ -58,6 +82,7 @@ jobs:
|
||||
EOF
|
||||
echo "Version info injected into utils/version.js:"
|
||||
cat utils/version.js
|
||||
|
||||
- name: Materialize the upload key
|
||||
env:
|
||||
WECHAT_CI_PRIVATE_KEY: ${{ secrets.WECHAT_CI_PRIVATE_KEY }}
|
||||
@@ -65,6 +90,7 @@ jobs:
|
||||
test -n "$WECHAT_CI_PRIVATE_KEY"
|
||||
umask 077
|
||||
printf '%s' "$WECHAT_CI_PRIVATE_KEY" > "$RUNNER_TEMP/wechat-ci.key"
|
||||
|
||||
- name: Upload WeChat development version
|
||||
working-directory: mini
|
||||
env:
|
||||
@@ -106,15 +132,7 @@ jobs:
|
||||
node ci/upload-ci.cjs
|
||||
test -s ci-artifacts/upload-result.json
|
||||
cat ci-artifacts/upload-result.json
|
||||
- name: Persist upload result on runner host
|
||||
run: |
|
||||
test -s mini/ci-artifacts/upload-result.json
|
||||
test -d /ci-artifacts
|
||||
cp mini/ci-artifacts/upload-result.json "/ci-artifacts/miniapp-upload-${{ gitea.sha }}.json"
|
||||
cp mini/ci-artifacts/upload-result.json /ci-artifacts/miniapp-upload-latest.json
|
||||
ls -la /ci-artifacts/miniapp-upload-latest.json
|
||||
echo "Upload result saved on runner host: /opt/lunar/ci-artifacts/miniapp-upload-latest.json"
|
||||
|
||||
|
||||
- name: Send success notification
|
||||
if: success()
|
||||
env:
|
||||
@@ -123,8 +141,8 @@ jobs:
|
||||
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
run: |
|
||||
VERSION="$(tr -d '\n' < mini/ci-artifacts/resolved-version.txt)"
|
||||
bash .gitea/scripts/notify.sh success "小程序开发版上传成功" "版本: ${VERSION} 上传结果已保存到: /opt/lunar/ci-artifacts/miniapp-upload-latest.json"
|
||||
|
||||
bash .gitea/scripts/notify.sh success "小程序开发版上传成功" "版本: ${VERSION}"
|
||||
|
||||
- name: Send failure notification
|
||||
if: failure()
|
||||
env:
|
||||
@@ -135,7 +153,7 @@ jobs:
|
||||
bash .gitea/scripts/notify.sh failure \
|
||||
"小程序开发版上传失败" \
|
||||
"请检查 Actions 日志了解失败原因"
|
||||
|
||||
|
||||
- name: Remove temporary credentials
|
||||
if: always()
|
||||
run: rm -f "$RUNNER_TEMP/wechat-ci.key"
|
||||
|
||||
Reference in New Issue
Block a user