name: Release # Wird bei einem vX.Y.Z-Tag-Push ausgeloest. Baut die drei Web-Extension-ZIPs # (Chrome/Firefox/Opera) und haengt sie ans passende Gitea-Release. # # Portiert von GitHub Actions auf Gitea Actions (2026-06): der fruehere # softprops/action-gh-release-Step ist GitHub-spezifisch und laeuft auf Gitea # nicht. Ersetzt durch die Gitea-native release-action (volle gitea.com-URL, # da DEFAULT_ACTIONS_URL=github nackte Namen sonst von github.com zieht). # Muster uebernommen aus HellionChat/.gitea/workflows/release.yml. on: push: tags: - 'v*' # Manueller Recovery-Trigger: in Gitea "Run workflow" und den Tag (z.B. v2.2.0) # im Ref-Dropdown waehlen, NICHT master. Der Validate-Step unten failt hart # bei einem Nicht-Tag-Ref, weil die release-action GITHUB_REF direkt liest. workflow_dispatch: permissions: contents: write jobs: build-release: name: Build & Release runs-on: ubuntu-latest timeout-minutes: 20 steps: # release-action liest GITHUB_REF direkt (kein tag_name-Input). Vorab # validieren, damit manuelle Dispatches von einem Branch-Ref hier laut # scheitern statt nach einem vollen Build. - name: Validate tag ref run: | if [[ "${GITHUB_REF}" != refs/tags/v* ]]; then echo "::error::Release-Workflow muss auf einem v*-Tag laufen, got ${GITHUB_REF}" echo "::error::Tag pushen, oder im workflow_dispatch-Ref-Dropdown den Tag (nicht master) waehlen." exit 1 fi - name: Checkout uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - name: Extract version from tag id: version run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" - name: Create Chrome/Edge ZIP (Manifest V3) run: | mkdir -p dist zip -r "dist/hellion-newtab-${{ steps.version.outputs.tag }}-chrome.zip" \ manifest.json newtab.html src/js/*.js src/css/ assets/ _locales/ \ -x "*.git*" "dist/*" ".github/*" ".gitea/*" "src/js/opera/*" - name: Create Firefox ZIP (Manifest V3) run: | cp manifest.json manifest.chrome-backup.json cp manifest.firefox.json manifest.json zip -r "dist/hellion-newtab-${{ steps.version.outputs.tag }}-firefox.zip" \ manifest.json newtab.html src/js/*.js src/css/ assets/ _locales/ \ -x "*.git*" "dist/*" ".github/*" ".gitea/*" "manifest.chrome-backup.json" "manifest.firefox.json" "src/js/opera/*" mv manifest.chrome-backup.json manifest.json - name: Create Opera/Opera GX ZIP (Manifest V3 + workaround) run: | cp manifest.json manifest.chrome-backup.json cp manifest.opera.json manifest.json zip -r "dist/hellion-newtab-${{ steps.version.outputs.tag }}-opera.zip" \ manifest.json newtab.html src/js/*.js src/js/opera/ src/css/ assets/ _locales/ \ -x "*.git*" "dist/*" ".github/*" ".gitea/*" "manifest.chrome-backup.json" "manifest.opera.json" mv manifest.chrome-backup.json manifest.json - name: Generate SHA256 checksums run: | cd dist sha256sum *.zip > checksums-sha256.txt cat checksums-sha256.txt # Release per Gitea-API (curl), NICHT via gitea.com/actions/release-action: die ist `using: go` # und stirbt auf diesem Runner mit exit 127 ("go not found"), weil act_runner v0.6.1 die go-Action # weder im Job-Image noch im Runner kompiliert bekommt. curl + python3 sind im Job-Image vorhanden # und laufen als normaler Step -> unabhaengig von go-Toolchain, Action-Cache und @main-Drift. # GITHUB_API_URL/GITHUB_REPOSITORY/GITHUB_TOKEN injiziert Gitea Actions automatisch. - name: Create release & upload assets (Gitea API) env: GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAG: ${{ steps.version.outputs.tag }} run: | set -euo pipefail API="${GITHUB_API_URL:-https://gitea.hellion-forge.cloud/api/v1}" REPO="${GITHUB_REPOSITORY}" AUTH="Authorization: token ${GITEA_TOKEN}" # Release-Request-JSON (Body inkl. Installationshinweise) als python-Einzeiler bauen # (mehrzeilig wuerde den YAML-run-Block brechen: Zeilen auf Spalte 0). REQ=$(python3 -c 'import json,os; t=os.environ["TAG"]; body="## Hellion NewTab "+t+"\n\n### Installation\n- **Chrome / Edge / Brave / Vivaldi:** `hellion-newtab-"+t+"-chrome.zip`\n- **Firefox:** `hellion-newtab-"+t+"-firefox.zip`\n- **Opera / Opera GX:** `hellion-newtab-"+t+"-opera.zip`\n\nVollstaendige Installationsanleitung siehe README.\n\n### Checksums\n`checksums-sha256.txt` zum Verifizieren der Dateiintegritaet."; print(json.dumps({"tag_name": t, "name": "Hellion NewTab "+t, "body": body}))') # Idempotent: existierendes Release zum Tag wiederverwenden, sonst anlegen. REL_ID=$(curl -sf -H "$AUTH" "$API/repos/$REPO/releases/tags/$TAG" \ | python3 -c 'import sys,json;print(json.load(sys.stdin).get("id",""))' 2>/dev/null || true) if [ -z "$REL_ID" ]; then REL_ID=$(printf '%s' "$REQ" \ | curl -sf -X POST -H "$AUTH" -H "Content-Type: application/json" -d @- "$API/repos/$REPO/releases" \ | python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])') echo "Release angelegt: $REL_ID" else echo "Release existiert bereits, wiederverwenden: $REL_ID" fi # Vorhandene gleichnamige Assets entfernen (idempotent bei Re-Runs), dann hochladen. EXIST=$(curl -sf -H "$AUTH" "$API/repos/$REPO/releases/$REL_ID/assets" 2>/dev/null || echo '[]') for f in dist/hellion-newtab-$TAG-chrome.zip dist/hellion-newtab-$TAG-firefox.zip dist/hellion-newtab-$TAG-opera.zip dist/checksums-sha256.txt; do name=$(basename "$f") aid=$(printf '%s' "$EXIST" | NAME="$name" python3 -c 'import sys,json,os;n=os.environ["NAME"];print(next((a["id"] for a in json.load(sys.stdin) if a.get("name")==n), ""))' 2>/dev/null || true) if [ -n "$aid" ]; then echo "ersetze vorhandenes Asset $name (id $aid)" curl -sf -X DELETE -H "$AUTH" "$API/repos/$REPO/releases/$REL_ID/assets/$aid" >/dev/null || true fi echo "Upload $name ..." curl -sf -X POST -H "$AUTH" -F "attachment=@$f" "$API/repos/$REPO/releases/$REL_ID/assets?name=$name" >/dev/null done echo "Release $TAG fertig: alle Assets hochgeladen."