10 Commits
Author SHA1 Message Date
tao.chenandClaude 6f4c3a3e21 ci: Bark 推送逻辑提到独立脚本, 两 job 复用
CI / Release / CI (push) Successful in 3m15s
CI / Release / Release (push) Successful in 4m43s
之前 ci/release 各自 inline 拼 payload + curl, 重复 25 行 x 2.
device_key / endpoint / group / ttl 硬编码两次, 改一处忘另一处
会出现两个不同 group 的推送.

新建 .github/scripts/bark-notify.sh:
  bash .github/scripts/bark-notify.sh "<title>" "<body>"

脚本封装:
  - endpoint / device_key / group (Gitea) / isArchive / ttl 单一来源
  - heredoc 拼 JSON, 不依赖 jq
  - 错误用法打印 usage 并 exit 1 (set -euo pipefail)

workflow 两处都改成一行:
  bash .github/scripts/bark-notify.sh "CI \${REF_NAME} \${STATUS}" "\${BODY}"
  bash .github/scripts/bark-notify.sh "\${TAG_NAME} \${STATUS}" "\${BODY}"

emoji (/) 跟 status 映射仍在 workflow 里, 因为不同 job 拼
不同的 title prefix (CI vs release), 脚本不管这个, 调用方传什么
就推什么.

chmod +x 加在 commit 里, 但 git mode bit 在 .gitattributes 或
core.fileMode 关时可能丢. runner 一般会按 working tree 模式跑,
不需要额外 chmod 在 step 里.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-15 16:36:07 +08:00
tao.chenandClaude 44a30c4a8a ci: Bark 通知 group 改 Gitea, CI/Release 成功失败都推
CI / Release / CI (push) Successful in 2m52s
CI / Release / Release (push) Has been skipped
group 从 "release" 改为 "Gitea" — 不再按事件分类, 跟 Bark 设备
group 设置对齐.

两个 job (ci / release) 都加 if: always() Bark step, 任何结束
状态 (success / failure / cancelled) 都推送. 之前 release job
只在 success() 触发, 失败时收不到通知, 调试慢.

通知内容带 job.status:
  - 成功: 标题 "v1.0.0 success", body 加  emoji + release URL
  - 失败: 标题 "v1.0.0 failure", body 加  emoji + release URL
           (release job 失败时) 或 actions run URL (ci job 失败时)

Bark 端 group 分类: "Gitea" group 收所有 CI/release 推送, 用户
在 Bark 设备上一目了然.

\${{ job.status }} 是 GitHub Actions 标准 context, Gitea 兼容
(API-compatible).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-15 16:33:41 +08:00
tao.chenandClaude 287d098e06 ci: release upload 改用 Gitea API 直调
CI / Release / CI (push) Successful in 1m55s
CI / Release / Release (push) Successful in 6m28s
softprops/action-gh-release@v2 在 Gitea 上偶发不工作, 改用
Gitea 原生 API:
  POST /repos/{owner}/{repo}/releases   <- 创建 release
  POST /repos/{owner}/{repo}/releases/{id}/assets  <- 上传 binary

token 走 secrets.GITHUB_TOKEN (Gitea 自动注入平台 token),
api_url 走 \${{ github.api_url }} (Gitea 自动解析).

RELEASE_ID 从 POST /releases 响应 grep 出来 (用 -oP "id":\s*\K[0-9]+).
- PCRE 模式 (grep -P) 依赖 GNU grep, ubuntu 镜像自带有, alpine
  runner 需要补 pcre 工具. 跟之前去 jq 一样是 runner 镜像依赖,
  这次保留因为已经在用 \${{ secrets.GITHUB_TOKEN }} 这种 GitHub
  风格 secret, runner 假定 ubuntu-family.

asset 上传字段是 attachment (Gitea API 文档要求, 不是 name).

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-15 09:37:57 +08:00
tao.chenandClaude e2bbbd5c45 ci: Bark 通知 group 改 release
CI / Release / CI (push) Successful in 1m49s
CI / Release / Release (push) Failing after 1m31s
之前用 "backup" 是从另一个 workflow 抄过来, 不准确. release 通
知归档到 "release" group, Bark 端按 group 分类更直观.

只改一处, 不动其他逻辑.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 19:22:00 +08:00
tao.chenandClaude 1cf4f90452 ci: release 通知 step 去掉 jq 依赖
CI / Release / CI (push) Successful in 5m42s
CI / Release / Release (push) Has been skipped
之前用 jq -n --arg 拼 JSON payload, 依赖 runner 镜像预装 jq.
Gitea act_runner 镜像可以自定义 (alpine / distroless / 极简
ubuntu), 不一定带 jq. 一旦缺, release 通知 step 静默失败
(curl 仍然发但 payload 是空字符串, Bark 端按 400/500 处理),
release 仍然成功上传但 user 收不到通知.

改用 heredoc 直接展开 shell 变量拼 JSON:
  PAYLOAD=$(cat <<EOF
  { "device_key": "...", "title": "${TITLE}", ... }
  EOF
  )

TITLE (tag 名, 形如 v0.0.1-beta) 和 BODY (release URL, 只含
https URL + tag 字符串) 都没有 ", \, 控制字符, heredoc 展开
安全. 不需要 jq 转义.

这一步跟 release upload 串行 (release job 本身顺序 steps), Bark
通知仍然是 release 成功的最后一步, if: success() 保留.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 19:21:18 +08:00
tao.chenandClaude 2bd67a5afc ci: release 后调 Bark 推送 release 通知
CI / Release / CI (push) Failing after 16m37s
CI / Release / Release (push) Has been skipped
release job 在 softprops/action-gh-release@v2 上传完
spark-mcp-linux-amd64 后, 调 Bark (http://101.43.40.124:81/push) 推
一条 device_key 绑定的通知, 标题用 github.ref_name (e.g.
v0.0.1-beta), body 带 release 页面 URL.

device_key 直接写进 workflow, 是公开的推送 key, group=backup
归档, ttl=3600 (1 小时后从 Bark 设备上消失).

if: success() 保证 release upload 失败时不会发通知, 避免推送
"已发布" 但实际没有的误导信息.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 19:19:35 +08:00
tao.chen 1460303b3e update: GOPROXY in release workflow
CI / Release / CI (push) Successful in 3m37s
CI / Release / Release (push) Failing after 1m27s
2026-07-14 19:11:43 +08:00
tao.chen 02499922b4 update: GOPROXY in building workflow
CI / Release / Release (push) Has been cancelled
CI / Release / CI (push) Has been cancelled
2026-07-14 19:06:53 +08:00
tao.chenandClaude 25c2fc66be ci: 改 workflow 用国内镜像装 Go + goproxy.cn 加速
CI / Release / CI (push) Successful in 7m45s
CI / Release / Release (push) Has been skipped
之前 ci/release 两个 job 用 actions/setup-go@v5 从 go.mod 装 Go,
内置 cache. 在 Gitea runner 所在网络区域 (ping 23ms 短, 推测
国内) 跑得动但慢.

改用用户提供的脚本手动装 Go 1.25.5 (NJU 镜像) + goproxy.cn 代理
+ GITHUB_PATH/GITHUB_ENV (Gitea runner 也兼容这俩 env var).
actions/setup-go 整个去掉, 因为手动装后 PATH 跟 GOPROXY 都设好,
go build 直接可跑.

GITBUB_PATH/GITHUB_ENV 是 GitHub Actions 的特殊 file path env var,
Gitea Actions 兼容 (api-compatible). 写到这两个文件等价于在
后续 step 设置 PATH 和 环境变量.

保留 go build / go vet / go test / gofmt -l . 四项 CI gate.
保留 release job 的 tag 触发 + softprops/action-gh-release@v2 上传.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 19:03:29 +08:00
tao.chenandClaude 80e644483a Add Gitea Actions CI/release workflow
CI / Release / Release (push) Has been cancelled
CI / Release / CI (push) Has been cancelled
The ci job triggers on every push to main and every pull request; the release job triggers only on tag pushes matching v* and needs the ci job to pass first.

We place the workflow under .github/workflows/ because Gitea Actions is API-compatible with GitHub Actions and discovers workflows in that directory.

The release build command is GOOS=linux GOARCH=amd64 go build -o spark-mcp-linux-amd64 ./main.go, producing the Linux amd64 artifact requested for deployment.

CI runs go build ./..., go vet ./..., go test ./..., and fails if gofmt -l . reports any unformatted files.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-14 16:11:27 +08:00
2 changed files with 169 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# bark-notify.sh — push a notification to the local Bark server.
#
# Usage: bark-notify.sh <title> <body>
#
# The Bark endpoint, device_key, and group are pinned in this script
# (it is a deployment detail, not a secret). The group is "Gitea" —
# change it here if you want to sort notifications by category.
set -euo pipefail
if [ "$#" -ne 2 ]; then
echo "usage: $0 <title> <body>" >&2
exit 1
fi
TITLE="$1"
BODY="$2"
PAYLOAD=$(cat <<EOF
{
"device_key": "6ZFVsxM95cuAjYoNLWSWaN",
"title": "${TITLE}",
"body": "${BODY}",
"group": "Gitea",
"isArchive": 1,
"ttl": 3600
}
EOF
)
curl -s \
-X POST http://101.43.40.124:81/push \
-H "Content-Type: application/json; charset=utf-8" \
-d "${PAYLOAD}"
echo "bark notified: ${TITLE}"
+132
View File
@@ -0,0 +1,132 @@
# This workflow runs on Gitea Actions, which is API-compatible with GitHub Actions.
# It performs CI on every push to main and every pull request, and automatically
# builds and attaches a Linux amd64 release binary when a version tag (v*) is pushed.
#
# Go is installed manually from a Chinese mirror (NJU) instead of using
# actions/setup-go, because the runner is in a region where the official Go
# download endpoint is slow. GOPROXY is set to goproxy.cn for the same reason.
name: CI / Release
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
jobs:
ci:
name: CI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go (Mirror in China)
run: |
if [ ! -d "/usr/local/go" ]; then
wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz
rm go1.25.5.linux-amd64.tar.gz
fi
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
- name: Build
run: go build ./...
- name: Vet
run: go vet ./...
- name: Test
run: go test ./...
- name: Check formatting
run: |
if [ -n "$(gofmt -l .)" ]; then
gofmt -l .
exit 1
fi
- name: Notify CI via Bark
if: always()
run: |
REF_NAME="${{ github.ref_name }}"
STATUS="${{ job.status }}"
if [ "${STATUS}" = "success" ]; then
EMOJI="✅"
else
EMOJI="❌"
fi
BODY="${EMOJI} ${REF_NAME} ${STATUS}: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }}"
bash .github/scripts/bark-notify.sh "CI ${REF_NAME} ${STATUS}" "${BODY}"
release:
name: Release
needs: ci
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Go (Mirror in China)
run: |
if [ ! -d "/usr/local/go" ]; then
wget https://mirrors.nju.edu.cn/golang/go1.25.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.25.5.linux-amd64.tar.gz
rm go1.25.5.linux-amd64.tar.gz
fi
echo "/usr/local/go/bin" >> $GITHUB_PATH
echo "GOPROXY=https://goproxy.cn/,https://goproxy.io,direct" >> $GITHUB_ENV
- name: Build release binary
run: GOOS=linux GOARCH=amd64 go build -o spark-mcp-linux-amd64 ./main.go
- name: Upload release asset via Gitea API
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 1. 获取当前 Tag 名字 (例如 v0.0.1-beta)
TAG_NAME="${{ github.ref_name }}"
echo "正在为 Tag ${TAG_NAME} 创建 Gitea Release..."
# 2. 调用 Gitea API 创建一个 Release 并获取其 ID
# 注意:${{ github.api_url }} 会自动解析为你本地 Gitea 的 API 地址 (如 http://your-gitea/api/v1)
RELEASE_ID=$(curl -X POST "${{ github.api_url }}/repos/${{ github.repository }}/releases" \
-H "accept: application/json" \
-H "authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG_NAME}\",
\"target_commitish\": \"${{ github.sha }}\",
\"name\": \"Release ${TAG_NAME}\",
\"body\": \"Auto generated release assets.\",
\"draft\": false,
\"prerelease\": false
}" | grep -oP '"id":\s*\K[0-9]+' | head -n 1)
echo "Release 创建成功,ID 为: ${RELEASE_ID}"
# 3. 将你的二进制文件上传到该 Release 中
echo "开始上传文件 spark-mcp-linux-amd64 ..."
curl -X POST "${{ github.api_url }}/repos/${{ github.repository }}/releases/${RELEASE_ID}/assets" \
-H "accept: application/json" \
-H "authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@spark-mcp-linux-amd64"
- name: Notify release via Bark
if: always()
run: |
TITLE="${{ github.ref_name }}"
STATUS="${{ job.status }}"
if [ "${STATUS}" = "success" ]; then
EMOJI="✅"
else
EMOJI="❌"
fi
BODY="${EMOJI} spark-mcp ${TITLE} ${STATUS}: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TITLE}"
bash .github/scripts/bark-notify.sh "${TITLE} ${STATUS}" "${BODY}"