Files
scriptforge/.gitea/workflows/deploy.yml
zhilv a12304a6a4
Some checks failed
Release / build-and-release (push) Failing after 2m54s
fix: 替换 setup-node/setup-go 为 shell 安装命令 (Gitea 无法访问 GitHub Actions)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-29 11:16:26 +08:00

82 lines
2.5 KiB
YAML

name: Release
on:
push:
tags:
- "v*"
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
run: |
apt-get update -qq
apt-get install -y -qq nodejs npm 2>/dev/null || true
node --version
npm --version
- name: Build frontend
run: |
cd frontend
npm ci
npm run build
- name: Setup Go
run: |
if ! command -v go &>/dev/null; then
apt-get install -y -qq golang-go 2>/dev/null || {
wget -q https://go.dev/dl/go1.22.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
echo "/usr/local/go/bin" >> "$GITHUB_PATH"
export PATH="$PATH:/usr/local/go/bin"
}
fi
go version
- name: Build all platforms
run: |
cp -r frontend/dist backend/internal/assets/dist/
cd backend
GOOS=linux GOARCH=amd64 go build -o scriptforge-server-linux-amd64 ./cmd/server
GOOS=linux GOARCH=arm64 go build -o scriptforge-server-linux-arm64 ./cmd/server
GOOS=windows GOARCH=amd64 go build -o scriptforge-server-windows-amd64.exe ./cmd/server
- name: Create Release
id: create_release
env:
GITEA_TOKEN: ${{ secrets.TOKEN }}
run: |
REPO="${{ gitea.repository }}"
TAG="${{ gitea.ref_name }}"
RELEASE_JSON=$(curl -s -X POST \
"https://gitea.kmux.cn/api/v1/repos/${REPO}/releases" \
-H "Authorization: token ${GITEA_TOKEN}" \
-H "Content-Type: application/json" \
-d "{
\"tag_name\": \"${TAG}\",
\"name\": \"${TAG}\",
\"body\": \"ScriptForge ${TAG}\",
\"draft\": false,
\"prerelease\": false
}")
echo "release_id=$(echo "$RELEASE_JSON" | jq -r '.id')" >> "$GITHUB_OUTPUT"
- name: Upload Release Assets
env:
GITEA_TOKEN: ${{ secrets.TOKEN }}
run: |
REPO="${{ gitea.repository }}"
RELEASE_ID="${{ steps.create_release.outputs.release_id }}"
for FILE in backend/scriptforge-server-*; do
echo "Uploading $FILE..."
curl -s -X POST \
"https://gitea.kmux.cn/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets" \
-H "Authorization: token ${GITEA_TOKEN}" \
-F "attachment=@${FILE}"
done