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>
100 lines
3.1 KiB
YAML
100 lines
3.1 KiB
YAML
# 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
|
|
|
|
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
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: spark-mcp-linux-amd64
|
|
generate_release_notes: true
|
|
|
|
- name: Notify release via Bark
|
|
if: success()
|
|
run: |
|
|
TITLE="${{ github.ref_name }}"
|
|
BODY="spark-mcp ${TITLE} released: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/releases/tag/${TITLE}"
|
|
curl -s \
|
|
-X POST http://101.43.40.124:81/push \
|
|
-H "Content-Type: application/json; charset=utf-8" \
|
|
-d "$(jq -n \
|
|
--arg device_key "6ZFVsxM95cuAjYoNLWSWaN" \
|
|
--arg title "$TITLE" \
|
|
--arg body "$BODY" \
|
|
'{
|
|
device_key: $device_key,
|
|
title: $title,
|
|
body: $body,
|
|
group: "backup",
|
|
isArchive: 1,
|
|
ttl: 3600
|
|
}')"
|