From da254bf264c60830958e06b0898628f5ccd98893 Mon Sep 17 00:00:00 2001 From: xefensor Date: Fri, 13 Nov 2026 08:56:03 +0000 Subject: [PATCH] Recover GitHub releases after a Modrinth post-upload failure Disable optional Modrinth unfeaturing in both publishers. Recover a missing GitHub prerelease from the checksum-verified file already published on Modrinth, without duplicating either mod-platform upload. Document partial-release recovery. --- .github/workflows/backfill-release.yml | 1 + .github/workflows/recover-github-release.yml | 95 ++++++++++++++++++++ .github/workflows/release.yml | 1 + docs/RELEASING.md | 16 +++- 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/recover-github-release.yml diff --git a/.github/workflows/backfill-release.yml b/.github/workflows/backfill-release.yml index b9dbff90..4697fae4 100644 --- a/.github/workflows/backfill-release.yml +++ b/.github/workflows/backfill-release.yml @@ -149,6 +149,7 @@ jobs: with: modrinth-id: ${{ vars.MODRINTH_PROJECT_ID }} modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + modrinth-unfeature-mode: none files: ${{ steps.artifact.outputs.jar }} name: Retold ${{ steps.version.outputs.version }} diff --git a/.github/workflows/recover-github-release.yml b/.github/workflows/recover-github-release.yml new file mode 100644 index 00000000..73e780c5 --- /dev/null +++ b/.github/workflows/recover-github-release.yml @@ -0,0 +1,95 @@ +name: Recover GitHub Release From Modrinth + +on: + workflow_dispatch: + inputs: + version: + description: 'Version already published on Modrinth, without the v prefix' + required: true + type: string + +permissions: + contents: write + +concurrency: + group: recover-github-release-${{ inputs.version }} + cancel-in-progress: false + +jobs: + recover: + runs-on: ubuntu-latest + env: + VERSION: ${{ inputs.version }} + MODRINTH_PROJECT_ID: ${{ vars.MODRINTH_PROJECT_ID }} + GH_TOKEN: ${{ github.token }} + steps: + - name: Validate version + shell: bash + run: | + [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][A-Za-z0-9.-]+)?$ ]] || exit 1 + [[ -n "$MODRINTH_PROJECT_ID" ]] || exit 1 + + - name: Checkout the existing release tag + uses: actions/checkout@v7 + with: + ref: v${{ inputs.version }} + fetch-depth: 0 + + - name: Refuse to replace an existing GitHub release + shell: bash + run: | + if gh release view "v$VERSION" >/dev/null 2>&1; then + echo 'The GitHub release already exists; inspect it instead of recreating it.' >&2 + exit 1 + fi + [[ "$(sed -n 's/^mod_version=//p' gradle.properties)" == "$VERSION" ]] + + - name: Download and verify the published Modrinth artifact + shell: bash + run: | + python3 - <<'PY' + import hashlib, json, os + from pathlib import Path + from urllib.parse import quote, urlparse + from urllib.request import Request, urlopen + version = os.environ['VERSION'] + project = os.environ['MODRINTH_PROJECT_ID'] + headers = {'User-Agent': 'xefensor/Retold release recovery (https://github.com/xefensor/Retold)'} + endpoint = f'https://api.modrinth.com/v2/project/{quote(project, safe="")}/version/{quote(version, safe="")}' + with urlopen(Request(endpoint, headers=headers), timeout=60) as response: + data = json.load(response) + assert data['project_id'] == project and data['version_number'] == version + assert data['version_type'] == 'alpha' and 'neoforge' in data['loaders'] and '26.2' in data['game_versions'] + files = data['files'] + artifact = next((file for file in files if file.get('primary')), files[0]) + name = f'retold-{version}.jar' + assert artifact['filename'] == name + assert urlparse(artifact['url']).scheme == 'https' and urlparse(artifact['url']).hostname == 'cdn.modrinth.com' + with urlopen(Request(artifact['url'], headers=headers), timeout=120) as response: + content = response.read() + assert hashlib.sha512(content).hexdigest() == artifact['hashes']['sha512'] + assert hashlib.sha1(content).hexdigest() == artifact['hashes']['sha1'] + destination = Path('release-assets'); destination.mkdir() + (destination / name).write_bytes(content) + checksum = hashlib.sha256(content).hexdigest() + (destination / (name + '.sha256')).write_text(f'{checksum} {name}\n') + print(f'Verified Modrinth version {data["id"]}: {name}, SHA-256 {checksum}') + print(f'https://modrinth.com/mod/retold/version/{data["id"]}') + PY + + - name: Extract the tagged release notes + shell: bash + run: | + awk -v version="$VERSION" ' + index($0, "## " version " - ") == 1 { capture = 1; next } + capture && /^## / { exit } + capture { print } + ' CHANGELOG.md > release-notes.md + [[ -s release-notes.md ]] + + - name: Create only the missing GitHub prerelease + shell: bash + run: | + gh release create "v$VERSION" --verify-tag --title "Retold $VERSION" --prerelease \ + --notes-file release-notes.md "release-assets/retold-$VERSION.jar" \ + "release-assets/retold-$VERSION.jar.sha256" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fb6ef1bd..9dad0a9c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -151,6 +151,7 @@ jobs: with: modrinth-id: ${{ vars.MODRINTH_PROJECT_ID }} modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + modrinth-unfeature-mode: none curseforge-id: ${{ vars.CURSEFORGE_PROJECT_ID }} curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 65958fd5..025e0a9c 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -94,8 +94,22 @@ When all checks pass, the workflow publishes: Retold currently publishes every version as **alpha** on Modrinth and CurseForge, and as a prerelease on GitHub. This is intentional even when the version is a plain number such as `0.2.1`. When Retold is ready to move to beta or stable, update the explicit `release_type` assignment in both publishing workflows. +Modrinth automatic unfeaturing is disabled. Version creation can succeed while the subsequent edit +of older versions fails, leaving the combined publisher partially complete. A failure during +unfeaturing does not imply that the new version is missing or that the token cannot upload. + ## Manual Recovery The workflow can also be started from **Actions → Release → Run workflow**. Enter the version without the `v` prefix. The entered version must still match `mod_version`, and every normal validation and publishing step still runs. -Use manual publishing only when the release tag workflow did not start. If a run partially publishes, first inspect GitHub, Modrinth, and CurseForge. Either upload the missing platform manually, or delete every version and GitHub release created by the failed run before retrying. The existing Git tag can remain in place. +Use manual publishing only when the release tag workflow did not start. If a run partially +publishes, inspect all three destinations before retrying; preserve the versions already uploaded. + +If Modrinth has the version but GitHub does not, run **Recover GitHub Release From Modrinth** on +`master` with that version. It checks out the existing tag, downloads the primary published JAR, +verifies its Modrinth SHA-512 and SHA-1 hashes, creates a SHA-256 checksum, and creates only the +missing GitHub prerelease. It does not rebuild, edit Modrinth, or upload to CurseForge. Afterward, +attach any separately prepared guide documents with `gh release upload`. + +If GitHub exists and another platform is missing, use **Backfill Existing Release**, enabling only +the missing destination. Do not rerun the combined release workflow for a partial publication.