Some checks failed
Release / build-and-release (push) Failing after 11m51s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
92 lines
2.8 KiB
YAML
92 lines
2.8 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build-and-release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.TOKEN }}
|
|
run: |
|
|
REPO="${{ gitea.repository }}"
|
|
TAG="${{ gitea.ref_name }}"
|
|
git clone --depth 1 --branch "${TAG}" \
|
|
"https://zhilv:${GITEA_TOKEN}@gitea.kmux.cn/${REPO}.git" .
|
|
git log --oneline -1
|
|
|
|
- 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
|