Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/backfill-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/recover-github-release.yml
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
16 changes: 15 additions & 1 deletion docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Loading