# 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 using launcher sources from DEFAULT BRANCH (so tags never miss # launcher files), checkout tag only for a consistent tree → download release attachments → 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 }} # Release tags often point at server/game commits that predate launcher lib fixes. # Always pack the launcher from default branch so app.asar includes the full tree. - name: Overlay launcher from default branch shell: bash run: | set -euo pipefail DB="${{ github.event.repository.default_branch }}" git fetch --no-tags --depth=1 origin "+refs/heads/${DB}:refs/remotes/origin/${DB}" git checkout "origin/${DB}" -- tools/fractured-launcher-electron - 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 run: | npm ci 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 }}"