Files
tekton/.gitea/workflows/ci.yml
T
2026-07-03 16:00:35 +08:00

120 lines
4.6 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Build & Release
runs-on: ubuntu-latest
timeout-minutes: 30
env:
GITEA_TOKEN: ${{ secrets.TEKTON_RELEASE_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
steps:
- uses: actions/checkout@v4
- name: Install tools
run: apt-get update -qq && apt-get install -y -qq docker.io curl unzip
- name: Connect job container to gitea_default network
run: docker network connect gitea_default $(hostname)
- name: Setup Godot
run: |
curl -sL -o /tmp/godot.zip "https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_linux.x86_64.zip"
unzip -q -o /tmp/godot.zip -d /usr/local/bin
chmod +x /usr/local/bin/godot*
mkdir -p /root/.godot/templates
if [ -f /cache/Godot_v4.6-stable_export_templates.tpz ]; then
cp /cache/Godot_v4.6-stable_export_templates.tpz /root/.godot/templates/
else
curl -sL -o /root/.godot/templates/Godot_v4.6-stable_export_templates.tpz \
"https://github.com/godotengine/godot-builds/releases/download/4.6-stable/Godot_v4.6-stable_export_templates.tpz"
fi
cd /root/.godot/templates && unzip -q -o Godot_v4.6-stable_export_templates.tpz
mkdir -p build
- name: Export Windows
run: |
cp addons/godotsteam/libgodotsteam* build/ 2>/dev/null || true
godot --headless --export-release "Windows" build/tekton_armageddon_windows.exe 2>&1 | tail -5
- name: Export Linux
run: godot --headless --export-release "Linux" build/tekton_armageddon_linux.x86_64 2>&1 | tail -5
- name: Build PCK
run: |
godot --headless --export-pack "Linux" build/tekton_armageddon.pck 2>&1 | tail -5
ls -lh build/
- name: Create Gitea Release
run: |
set -e
API="http://gitea:3000/api/v1/repos/danchie/tekton/releases"
TAG="$TAG_NAME"
echo "Checking existing release for $TAG..."
RELEASE_JSON=$(curl -s -H "Authorization: token $GITEA_TOKEN" "$API/tags/$TAG")
RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*' || true)
if [ -z "$RELEASE_ID" ]; then
echo "Creating new release for $TAG..."
RELEASE_JSON=$(curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"draft\":true}" \
"$API")
echo "API response: $RELEASE_JSON"
RELEASE_ID=$(echo "$RELEASE_JSON" | grep -o '"id":[0-9]*' | head -1 | grep -o '[0-9]*')
if [ -z "$RELEASE_ID" ]; then
echo "FATAL: Could not create release"
exit 1
fi
fi
echo "release_id=$RELEASE_ID"
echo "$RELEASE_ID" > /tmp/release_id.txt
- name: Upload Windows asset
run: |
RELEASE_ID=$(cat /tmp/release_id.txt)
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon_windows.exe" \
"http://gitea:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "Windows uploaded"
- name: Upload Linux asset
run: |
RELEASE_ID=$(cat /tmp/release_id.txt)
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon_linux.x86_64" \
"http://gitea:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "Linux uploaded"
- name: Upload PCK asset
run: |
RELEASE_ID=$(cat /tmp/release_id.txt)
curl -s -X POST \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: multipart/form-data" \
-F "attachment=@build/tekton_armageddon.pck" \
"http://gitea:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID/assets"
echo "PCK uploaded"
- name: Publish release
run: |
RELEASE_ID=$(cat /tmp/release_id.txt)
curl -s -X PATCH \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d '{"draft":false}' \
"http://gitea:3000/api/v1/repos/danchie/tekton/releases/$RELEASE_ID"
echo "Published: https://git.klud.top/danchie/tekton/releases/tag/$TAG_NAME"