Compare commits
17
Commits
25f93dfb59
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f026946b6 | ||
|
|
c02479381f | ||
|
|
ec5292f9f7 | ||
|
|
fefd816a21 | ||
|
|
2571ce69c0 | ||
|
|
160c9f32c8 | ||
|
|
e5f7d661b4 | ||
|
|
6f4c3a3e21 | ||
|
|
44a30c4a8a | ||
|
|
287d098e06 | ||
|
|
e2bbbd5c45 | ||
|
|
1cf4f90452 | ||
|
|
2bd67a5afc | ||
|
|
1460303b3e | ||
|
|
02499922b4 | ||
|
|
25c2fc66be | ||
|
|
80e644483a |
Executable
+37
@@ -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}"
|
||||||
@@ -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@v6
|
||||||
|
|
||||||
|
- 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@v6
|
||||||
|
|
||||||
|
- 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}"
|
||||||
Reference in New Issue
Block a user