name: Build & Release Pack on: push: branches: [main] tags: ['v*'] jobs: build: runs-on: docker steps: - name: Environment check run: | echo "cwd: $(pwd)" echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" python3 --version; git --version 2>/dev/null || echo "git: MISSING" curl --version 2>/dev/null | head -1 || echo "curl: MISSING" tar --version 2>/dev/null | head -1 || echo "tar: MISSING" - name: Fetch sources run: | if command -v git >/dev/null 2>&1; then echo "git present -> cloning" git clone --branch "${GITHUB_REF_NAME}" --depth 1 "https://x-access-token:${GITHUB_TOKEN}@git.mithraic.cloud/ad3laid3/FKRPG.git" "${GITHUB_WORKSPACE}" else echo "git missing -> downloading archive via API" python3 - <<'PY' import urllib.request, tarfile, io, os, shutil ws = os.environ.get('GITHUB_WORKSPACE') or os.getcwd() sha = os.environ['GITHUB_SHA'] token = os.environ.get('GITHUB_TOKEN', '') url = f"https://git.mithraic.cloud/api/v1/repos/ad3laid3/FKRPG/archive/{sha}.tar.gz" req = urllib.request.Request(url, headers={"Authorization": f"token {token}"}) raw = urllib.request.urlopen(req, timeout=120).read() os.makedirs('/tmp/fkrpg_src', exist_ok=True) with tarfile.open(fileobj=io.BytesIO(raw)) as tf: tf.extractall('/tmp/fkrpg_src') src = os.path.join('/tmp/fkrpg_src', os.listdir('/tmp/fkrpg_src')[0]) for name in os.listdir(src): dst = os.path.join(ws, name) if os.path.exists(dst): shutil.rmtree(dst) if os.path.isdir(dst) else os.remove(dst) shutil.move(os.path.join(src, name), dst) print("Extracted sources into", ws) PY fi - name: Refresh index working-directory: client_pack run: ../tools/packwiz refresh - name: Integrity check working-directory: client_pack run: python3 ../tools/validate_pack.py . integrity - name: Sanity grep download URLs working-directory: client_pack run: python3 ../tools/validate_pack.py . sanity - name: Export client Modrinth pack working-directory: client_pack run: ../tools/packwiz modrinth export -o ../FKRPG-${GITHUB_REF_NAME}.mrpack --restrictDomains=false - name: Refresh server index working-directory: server_pack run: ../tools/packwiz refresh - name: Integrity check (server) working-directory: server_pack run: python3 ../tools/validate_pack.py . integrity - name: Sanity grep download URLs (server) working-directory: server_pack run: python3 ../tools/validate_pack.py . sanity - name: Export server Modrinth pack working-directory: server_pack run: ../tools/packwiz modrinth export -o ../FKRPG-SERVER-${GITHUB_REF_NAME}.mrpack --restrictDomains=false - name: Release if: startsWith(github.ref, 'refs/tags/v') run: | set -e TAG="${GITHUB_REF_NAME}" API="https://git.mithraic.cloud/api/v1/repos/ad3laid3/FKRPG/releases" AUTH="Authorization: token ${{ secrets.GITHUB_TOKEN }}" RELEASE_JSON=$(curl -sS -X POST "$API" \ -H "$AUTH" \ -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"FKRPG $TAG\",\"body\":\"Download the .mrpack and import it into Prism Launcher (File > Import Instance > select the file). All mods are bundled or auto-fetched. Use the SERVER pack on the server side. Worldgen tuned for realistic+expansive RPG (Tectonic+Terralith+Continents).\"}") RELEASE_ID=$(printf '%s' "$RELEASE_JSON" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") for mr in "FKRPG-${TAG}.mrpack" "FKRPG-SERVER-${TAG}.mrpack"; do curl -sS -X POST "$API/$RELEASE_ID/assets?name=${mr}" \ -H "$AUTH" \ -F "attachment=@${mr}" done echo "Uploaded FKRPG-${TAG}.mrpack and FKRPG-SERVER-${TAG}.mrpack"