7028258084
- inject-release-channel.js merges GITEA_* (or fractured-release-channel.json) into default-launcher.json before electron-builder. - CI passes existing GITEA_BASE_URL/OWNER/REPO secrets into the Windows pack job. - npm run pack:win/publish:win run the injector; workflows use npm run pack:win. Co-authored-by: Cursor <cursoragent@cursor.com>
165 lines
6.0 KiB
YAML
165 lines
6.0 KiB
YAML
# Primary path for player-facing binaries: every *published* GitHub Release on this repo
|
||
# is mirrored to your self-hosted Gitea (same tag). No public GitHub distro repo.
|
||
#
|
||
# Triggers:
|
||
# - release: published / released → GitHub “Release” (not a raw git tag alone).
|
||
# - workflow_dispatch → Actions → this workflow → “Run workflow” (enter tag).
|
||
#
|
||
# Troubleshooting: “Re-run failed jobs” on an OLD run replays the *original* workflow
|
||
# YAML (e.g. still runs `npm run pack:win` without --publish never). After changing this
|
||
# file on default branch, start a *new* run via “Run workflow”, not Re-run on a pre-fix run.
|
||
#
|
||
# Important: pushing only a git tag does NOT run this — you must create/publish a
|
||
# Release on github.com (Releases → Draft/new release → Publish). The workflow
|
||
# definition must exist on the repo DEFAULT branch (GitHub runs it from there).
|
||
#
|
||
# Steps: build Electron from tag → download this repo’s release attachments → upload all to Gitea.
|
||
#
|
||
# Secrets: GITEA_BASE_URL, GITEA_TOKEN, GITEA_OWNER, GITEA_REPO
|
||
# Optional variable: GITEA_TARGET_REF (see tools/fractured-launcher-electron/README.md)
|
||
#
|
||
# Job guard: edit `if:` if github.repository is not Dawnforger/Fractured.
|
||
|
||
name: Sync release to Gitea
|
||
|
||
on:
|
||
release:
|
||
types: [published, released]
|
||
workflow_dispatch:
|
||
inputs:
|
||
tag:
|
||
description: 'Release tag on this GitHub repo (must exist; e.g. v1.0.0)'
|
||
required: true
|
||
type: string
|
||
|
||
permissions:
|
||
contents: read
|
||
|
||
concurrency:
|
||
group: gitea-release-sync-${{ github.repository }}-${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || github.event.release.tag_name }}
|
||
cancel-in-progress: false
|
||
|
||
jobs:
|
||
meta:
|
||
runs-on: ubuntu-latest
|
||
if: github.repository == 'Dawnforger/Fractured'
|
||
outputs:
|
||
tag: ${{ steps.t.outputs.tag }}
|
||
steps:
|
||
- name: Resolve tag
|
||
id: t
|
||
shell: bash
|
||
run: |
|
||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||
echo "tag=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
|
||
else
|
||
echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
|
||
fi
|
||
|
||
build-electron:
|
||
needs: meta
|
||
if: github.repository == 'Dawnforger/Fractured'
|
||
runs-on: windows-latest
|
||
timeout-minutes: 45
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
with:
|
||
ref: ${{ needs.meta.outputs.tag }}
|
||
|
||
- uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
cache: npm
|
||
cache-dependency-path: tools/fractured-launcher-electron/package-lock.json
|
||
|
||
- name: Install and pack (NSIS + portable)
|
||
working-directory: tools/fractured-launcher-electron
|
||
env:
|
||
# Same values as upload step — baked into default-launcher.json (no token).
|
||
GITEA_BASE_URL: ${{ secrets.GITEA_BASE_URL }}
|
||
GITEA_OWNER: ${{ secrets.GITEA_OWNER }}
|
||
GITEA_REPO: ${{ secrets.GITEA_REPO }}
|
||
run: |
|
||
npm ci
|
||
# pack:win runs inject-release-channel.js then electron-builder --publish never
|
||
npm run pack:win
|
||
|
||
- name: Stage launcher files for upload
|
||
shell: pwsh
|
||
run: |
|
||
New-Item -ItemType Directory -Force -Path launcher-publish | Out-Null
|
||
Copy-Item tools/fractured-launcher-electron/dist/*.exe launcher-publish/
|
||
if (Test-Path tools/fractured-launcher-electron/dist/latest.yml) {
|
||
Copy-Item tools/fractured-launcher-electron/dist/latest.yml launcher-publish/
|
||
}
|
||
Get-ChildItem tools/fractured-launcher-electron/dist/*.blockmap -ErrorAction SilentlyContinue |
|
||
Copy-Item -Destination launcher-publish/
|
||
|
||
- uses: actions/upload-artifact@v4
|
||
with:
|
||
name: electron-dist
|
||
path: launcher-publish/
|
||
|
||
sync-gitea:
|
||
needs: [meta, build-electron]
|
||
if: github.repository == 'Dawnforger/Fractured'
|
||
runs-on: ubuntu-latest
|
||
env:
|
||
GITEA_BASE_URL: ${{ secrets.GITEA_BASE_URL }}
|
||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||
GITEA_OWNER: ${{ secrets.GITEA_OWNER }}
|
||
GITEA_REPO: ${{ secrets.GITEA_REPO }}
|
||
GITEA_TARGET_REF: ${{ vars.GITEA_TARGET_REF }}
|
||
steps:
|
||
- uses: actions/checkout@v4
|
||
with:
|
||
# Script may not exist on older release tags; always use default branch.
|
||
ref: ${{ github.event.repository.default_branch }}
|
||
sparse-checkout: |
|
||
tools/fractured-launcher-electron/scripts
|
||
sparse-checkout-cone-mode: true
|
||
|
||
- uses: actions/download-artifact@v4
|
||
with:
|
||
name: electron-dist
|
||
path: /tmp/electron
|
||
|
||
- name: Merge GitHub release assets + Electron build
|
||
env:
|
||
GH_TOKEN: ${{ github.token }}
|
||
run: |
|
||
set -euo pipefail
|
||
TAG="${{ needs.meta.outputs.tag }}"
|
||
mkdir -p combined
|
||
mkdir -p /tmp/from-main
|
||
if gh release download "$TAG" -R "${{ github.repository }}" -D /tmp/from-main 2>/tmp/dl.err; then
|
||
shopt -s nullglob
|
||
for f in /tmp/from-main/*; do
|
||
if [ -f "$f" ]; then
|
||
cp -f "$f" combined/
|
||
fi
|
||
done
|
||
echo "Merged assets from ${{ github.repository }} release $TAG"
|
||
else
|
||
echo "GitHub release download note (continuing with launcher only):"
|
||
cat /tmp/dl.err || true
|
||
fi
|
||
shopt -s nullglob
|
||
for f in /tmp/electron/*; do
|
||
if [ -f "$f" ]; then
|
||
cp -f "$f" combined/
|
||
fi
|
||
done
|
||
ls -la combined/
|
||
|
||
- name: Upload to Gitea
|
||
run: |
|
||
set -euo pipefail
|
||
for v in GITEA_BASE_URL GITEA_TOKEN GITEA_OWNER GITEA_REPO; do
|
||
if [ -z "${!v:-}" ]; then
|
||
echo "Missing secret $v — add it under repo Settings → Secrets and variables → Actions." >&2
|
||
exit 1
|
||
fi
|
||
done
|
||
bash tools/fractured-launcher-electron/scripts/upload-release-to-gitea.sh combined "${{ needs.meta.outputs.tag }}"
|