From 12e580ba518039365b4a27fcf4d904860ad0bb5e Mon Sep 17 00:00:00 2001 From: John Braham Date: Tue, 1 Dec 2026 11:06:15 +0000 Subject: [PATCH] Add Modrinth release backfill --- .github/MODRINTH.md | 27 +++ .github/scripts/modrinth-release.mjs | 194 ++++++++++++++++++++ .github/scripts/modrinth-release.test.mjs | 92 ++++++++++ .github/workflows/ci.yml | 12 +- .github/workflows/codeql-analysis.yml | 12 +- .github/workflows/modrinth-checks.yml | 23 +++ .github/workflows/publish-modrinth.yml | 89 +++++++++ .github/workflows/validate-gradle-build.yml | 12 +- 8 files changed, 458 insertions(+), 3 deletions(-) create mode 100644 .github/MODRINTH.md create mode 100644 .github/scripts/modrinth-release.mjs create mode 100644 .github/scripts/modrinth-release.test.mjs create mode 100644 .github/workflows/modrinth-checks.yml create mode 100644 .github/workflows/publish-modrinth.yml diff --git a/.github/MODRINTH.md b/.github/MODRINTH.md new file mode 100644 index 00000000..5d956fed --- /dev/null +++ b/.github/MODRINTH.md @@ -0,0 +1,27 @@ +# Copying published releases to Modrinth + +Run **Copy published OreSpawn releases to Modrinth** from the MMD repository's +Actions page. Enter a published four-part version, or `latest-published` to +copy the newest stable OreSpawn 4 release for each Minecraft version and loader. +Tick the confirmation box to publish. The repository needs a `MODRINTH_TOKEN` +secret with permission to create versions on the MMD OreSpawn project. + +This workflow downloads existing GitHub release jars, checks their published +SHA-256 checksums and checks the public CurseForge main-file metadata. It does +not build code, create release tags, change dependencies or publish to Maven or +CurseForge. Local candidates and unreleased branches are never selected. + +Each Modrinth version keeps the original version number, release notes, exact +Minecraft version and loader. The ordinary jar is the primary download; source +and Javadoc jars are additional files. Modrinth records the upload date, not the +original release date. + +An identical existing upload is reused. A conflicting version number, loader, +file set or checksum stops publication rather than replacing files. After an +upload the workflow downloads all three files anonymously and verifies them +against the original release checksums. Its receipt is retained as an Actions +artifact. If verification fails after uploading, inspect the receipt and public +version before retrying; do not delete or publish another copy blindly. + +The normal release workflow is unchanged. For a future release, run this copy +workflow after its GitHub and CurseForge files are public. diff --git a/.github/scripts/modrinth-release.mjs b/.github/scripts/modrinth-release.mjs new file mode 100644 index 00000000..dd3e33c0 --- /dev/null +++ b/.github/scripts/modrinth-release.mjs @@ -0,0 +1,194 @@ +import assert from 'node:assert/strict'; +import { createHash, randomUUID } from 'node:crypto'; +import { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import { pathToFileURL } from 'node:url'; + +export const repository = 'MinecraftModDevelopmentMods/OreSpawn'; +export const project = 'cXWN0TpD'; + +export function latestPublished(releases) { + const latest = new Map(); + for (const release of releases) { + if (release.draft || release.prerelease || !/^4\.\d+\.\d+\.\d+$/.test(release.tag_name)) continue; + const parts = release.tag_name.split('.').map(Number); + const previous = latest.get(parts[3]); + const older = previous?.split('.').map(Number); + if (!older || parts[1] > older[1] || (parts[1] === older[1] && parts[2] > older[2])) { + latest.set(parts[3], release.tag_name); + } + } + return [...latest.values()].sort((a, b) => Number(a.split('.')[3]) - Number(b.split('.')[3])); +} + +export function releaseMetadata(version, properties) { + assert.match(version, /^4\.\d+\.\d+\.\d+$/); + const values = Object.fromEntries(properties.split(/\r?\n/).filter(line => /^[a-z_]+=/.test(line)) + .map(line => [line.slice(0, line.indexOf('=')), line.slice(line.indexOf('=') + 1).trim()])); + assert.equal(values.mod_id, 'orespawn'); + assert.equal(values.mod_version, version, 'Tagged version differs from the requested release'); + assert.ok(['forge', 'neoforge'].includes(values.loader_name), 'Unsupported loader'); + assert.equal(values.curseforge_project_id, '245586'); + const minecraft = values.minecraft_version?.split('.').map(Number); + assert.ok(minecraft?.length >= 2 && minecraft.length <= 3 && minecraft.every(Number.isInteger), 'Invalid Minecraft version'); + const suffix = `${minecraft[0]}${String(minecraft[1]).padStart(2, '0')}${String(minecraft[2] ?? 0).padStart(2, '0')}${values.loader_name === 'forge' ? 1 : 2}`; + assert.equal(version.split('.')[3], suffix, 'Minecraft version or loader differs from the release suffix'); + const base = `OreSpawn-${version}`; + return { + version, minecraft: values.minecraft_version, loader: values.loader_name, + name: `OreSpawn ${version} for Minecraft ${values.minecraft_version} (${values.loader_name === 'forge' ? 'Forge' : 'NeoForge'})`, + files: [`${base}.jar`, `${base}-sources.jar`, `${base}-javadoc.jar`], + }; +} + +export function checksumFor(manifest, filename) { + const matches = manifest.split(/\r?\n/).map(line => /^([a-fA-F0-9]{64})\s+\*?(.+)$/.exec(line)) + .filter(match => match?.[2] === filename); + assert.equal(matches.length, 1, `Expected one published checksum for ${filename}`); + return matches[0][1].toLowerCase(); +} + +export function matchingVersion(versions, metadata, hashes) { + const matches = versions.filter(version => version.version_number === metadata.version); + assert.ok(matches.length <= 1, 'Multiple Modrinth versions use this release number'); + if (!matches.length) return undefined; + const existing = matches[0]; + assert.equal(existing.project_id, project, 'Existing Modrinth project differs'); + assert.equal(existing.status, 'listed', 'Existing Modrinth version is not public'); + assert.deepEqual(existing.game_versions, [metadata.minecraft], 'Existing Minecraft metadata differs'); + assert.deepEqual(existing.loaders, [metadata.loader], 'Existing loader differs'); + assert.equal(existing.version_type, 'release', 'Existing release channel differs'); + assert.deepEqual(existing.dependencies, [], 'OreSpawn does not require another mod'); + assert.equal(existing.files.length, metadata.files.length, 'Existing file set differs'); + for (const filename of metadata.files) { + const file = existing.files.find(file => file.filename === filename); + assert.equal(file?.hashes.sha512, hashes[filename].sha512, `Existing file differs: ${filename}`); + assert.equal(file.size, hashes[filename].bytes, `Existing file size differs: ${filename}`); + assert.equal(file.primary, filename === metadata.files[0], 'Existing primary file differs'); + } + return existing; +} + +export async function json(url, { allowNotFound = false } = {}) { + const headers = { 'User-Agent': 'OreSpawn-release/1.0 (github.com/MinecraftModDevelopmentMods/OreSpawn)' }; + if (url.startsWith('https://api.github.com/') && process.env.GH_TOKEN) headers.Authorization = `Bearer ${process.env.GH_TOKEN}`; + const response = await fetch(url, { headers, signal: AbortSignal.timeout(60000) }); + if (allowNotFound && response.status === 404) return undefined; + assert.ok(response.ok, `Request failed (${response.status}): ${url}`); + return response.json(); +} + +export async function findExistingVersion(metadata, hashes, request = json) { + // The project-wide version listing can lag behind a successful upload. + const version = await request(`https://api.modrinth.com/v2/project/${project}/version/${encodeURIComponent(metadata.version)}`, { allowNotFound: true }); + return matchingVersion(version ? [version] : [], metadata, hashes); +} + +async function output(name, value) { + if (!process.env.GITHUB_OUTPUT) return; + const delimiter = randomUUID(); + await appendFile(process.env.GITHUB_OUTPUT, `${name}<<${delimiter}\n${value}\n${delimiter}\n`); +} + +export async function selectVersions() { + const requested = process.env.RELEASE_VERSION; + let versions = [requested]; + if (requested === 'latest-published') { + const releases = []; + for (let page = 1; ; page++) { + const batch = await json(`https://api.github.com/repos/${repository}/releases?per_page=100&page=${page}`); + releases.push(...batch); + if (batch.length < 100) break; + } + versions = latestPublished(releases); + assert.ok(versions.length, 'No published OreSpawn 4 releases found'); + } + for (const version of versions) assert.match(version, /^4\.\d+\.\d+\.\d+$/); + await output('versions', JSON.stringify(versions)); + console.log(JSON.stringify(versions)); + return versions; +} + +export function publicCurseForgeFile(files, metadata, mainSize) { + const matches = files.filter(file => file.name === metadata.files[0]); + assert.equal(matches.length, 1, 'Expected one public CurseForge main file'); + const file = matches[0]; + assert.equal(file.type, 'release'); + assert.equal(file.filesize, mainSize, 'CurseForge size differs from GitHub'); + assert.ok(file.versions.includes(metadata.minecraft), 'CurseForge Minecraft metadata differs'); + assert.ok(file.versions.includes(metadata.loader === 'forge' ? 'Forge' : 'NeoForge'), 'CurseForge loader differs'); + assert.ok(!file.versions.includes(metadata.loader === 'forge' ? 'NeoForge' : 'Forge'), 'CurseForge loader is ambiguous'); + return { id: file.id, url: file.url }; +} + +export async function prepare(directory) { + const version = process.env.RELEASE_VERSION; + assert.match(version ?? '', /^4\.\d+\.\d+\.\d+$/); + const release = await json(`https://api.github.com/repos/${repository}/releases/tags/${version}`); + assert.ok(!release.draft && !release.prerelease, 'Only published stable releases can be copied'); + const source = await json(`https://api.github.com/repos/${repository}/contents/gradle.properties?ref=${version}`); + const metadata = releaseMetadata(version, Buffer.from(source.content, 'base64').toString('utf8')); + const modrinthProject = await json(`https://api.modrinth.com/v2/project/${project}`); + assert.equal(modrinthProject.source_url, `https://github.com/${repository}`); + assert.equal(modrinthProject.status, 'approved'); + await mkdir(directory, { recursive: true }); + for (const filename of [...metadata.files, 'SHA256SUMS']) { + const asset = release.assets.find(asset => asset.name === filename); + assert.ok(asset, `Published release is missing ${filename}`); + const response = await fetch(asset.browser_download_url, { signal: AbortSignal.timeout(120000) }); + assert.ok(response.ok, `Published asset download failed: ${filename}`); + const bytes = Buffer.from(await response.arrayBuffer()); + assert.equal(bytes.length, asset.size, `Published size differs: ${filename}`); + if (asset.digest) assert.equal(`sha256:${createHash('sha256').update(bytes).digest('hex')}`, asset.digest); + await writeFile(join(directory, filename), bytes, { flag: 'wx' }); + } + const manifest = await readFile(join(directory, 'SHA256SUMS'), 'utf8'); + const hashes = {}; + for (const filename of metadata.files) { + const bytes = await readFile(join(directory, filename)); + const sha256 = createHash('sha256').update(bytes).digest('hex'); + assert.equal(sha256, checksumFor(manifest, filename), `Published SHA256 mismatch: ${filename}`); + hashes[filename] = { sha256, sha512: createHash('sha512').update(bytes).digest('hex'), bytes: bytes.length }; + } + const widget = await json('https://api.cfwidget.com/245586'); + const curseforge = publicCurseForgeFile(widget.files, metadata, hashes[metadata.files[0]].bytes); + const existing = await findExistingVersion(metadata, hashes); + // Keep the original public notes, including their links and release history. + await writeFile(join(directory, 'CHANGELOG.md'), release.body || `[Release notes](${release.html_url})\n`, { flag: 'wx' }); + await writeFile(join(directory, 'modrinth-receipt.json'), JSON.stringify({ metadata, hashes, curseforge, githubRelease: release.html_url, existingVersion: existing?.id }, null, 2)); + for (const [name, value] of Object.entries({ name: metadata.name, minecraft: metadata.minecraft, loader: metadata.loader, + files: metadata.files.map(file => join(directory, file)).join('\n'), publish: String(!existing), existing_version: existing?.id ?? '' })) await output(name, value); + console.log(`${version}: ${existing ? 'identical release already published' : 'published files verified and ready to copy'}`); +} + +export async function verify(directory) { + const receipt = JSON.parse(await readFile(join(directory, 'modrinth-receipt.json'), 'utf8')); + const id = process.env.MODRINTH_VERSION; + assert.match(id ?? '', /^[a-zA-Z0-9]+$/, 'Missing Modrinth version ID'); + const published = await json(`https://api.modrinth.com/v2/version/${id}`); + const version = matchingVersion([published], receipt.metadata, receipt.hashes); + assert.ok(version, 'Published version number differs'); + assert.equal(version.environment, 'client_and_server'); + for (const file of version.files) { + const response = await fetch(file.url, { signal: AbortSignal.timeout(120000) }); + assert.ok(response.ok, `Public Modrinth download failed: ${file.filename}`); + const bytes = Buffer.from(await response.arrayBuffer()); + assert.equal(bytes.length, receipt.hashes[file.filename].bytes); + assert.equal(createHash('sha256').update(bytes).digest('hex'), receipt.hashes[file.filename].sha256); + } + receipt.publishedVersion = version.id; + receipt.publicDownloadsVerified = true; + receipt.verifiedAt = new Date().toISOString(); + receipt.url = `https://modrinth.com/mod/mmd-orespawn/version/${version.id}`; + await writeFile(join(directory, 'modrinth-receipt.json'), JSON.stringify(receipt, null, 2)); + console.log(`Verified public release ${receipt.url}`); +} + +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + assert.equal(process.env.GITHUB_REPOSITORY, repository, 'Publishing is restricted to the MMD repository'); + const directory = join(process.env.RUNNER_TEMP, 'release-input'); + if (process.argv[2] === 'select') await selectVersions(); + else if (process.argv[2] === 'prepare') await prepare(directory); + else if (process.argv[2] === 'verify') await verify(directory); + else throw new Error(`Unknown command: ${process.argv[2]}`); +} diff --git a/.github/scripts/modrinth-release.test.mjs b/.github/scripts/modrinth-release.test.mjs new file mode 100644 index 00000000..e37c5e6c --- /dev/null +++ b/.github/scripts/modrinth-release.test.mjs @@ -0,0 +1,92 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { checksumFor, findExistingVersion, latestPublished, matchingVersion, publicCurseForgeFile, releaseMetadata } from './modrinth-release.mjs'; + +const properties = 'mod_id=orespawn\nmod_version=4.1.1.121012\nminecraft_version=1.21.1\nloader_name=neoforge\ncurseforge_project_id=245586'; +const metadata = releaseMetadata('4.1.1.121012', properties); +const hashes = Object.fromEntries(metadata.files.map(file => [file, { sha512: 'abc', bytes: 42 }])); +const existing = { + id: 'existing', project_id: 'cXWN0TpD', version_number: metadata.version, + game_versions: [metadata.minecraft], loaders: [metadata.loader], status: 'listed', + version_type: 'release', dependencies: [], + files: metadata.files.map((filename, index) => ({ filename, primary: index === 0, size: 42, hashes: { sha512: 'abc' } })), +}; + +test('select the latest public stable release per target, including targets still on 4.0', () => { + const releases = ['4.1.1.121012', '4.1.7.121011', '4.0.16.2602002', '4.0.20.121011', '4.1.2.121012', '3.3.1', '4.2.0.121011'].map(tag_name => ({ tag_name })); + releases.push({ tag_name: '4.2.1.121011', prerelease: true }, { tag_name: '4.9.9.121012', draft: true }); + assert.deepEqual(latestPublished(releases), ['4.2.0.121011', '4.1.2.121012', '4.0.16.2602002']); +}); + +test('metadata comes from the exact published tag and produces the three existing filenames', () => { + assert.equal(metadata.minecraft, '1.21.1'); + assert.equal(metadata.loader, 'neoforge'); + assert.deepEqual(metadata.files, ['OreSpawn-4.1.1.121012.jar', 'OreSpawn-4.1.1.121012-sources.jar', 'OreSpawn-4.1.1.121012-javadoc.jar']); + const forge = releaseMetadata('4.1.7.110021', properties.replace('4.1.1.121012', '4.1.7.110021').replace('1.21.1', '1.10.2').replace('neoforge', 'forge')); + assert.equal(forge.loader, 'forge'); + const modern = releaseMetadata('4.0.16.2602002', properties.replace('4.1.1.121012', '4.0.16.2602002').replace('1.21.1', '26.2')); + assert.equal(modern.minecraft, '26.2'); +}); + +for (const [label, changed] of [ + ['wrong mod', properties.replace('mod_id=orespawn', 'mod_id=another')], + ['wrong version', properties.replace('mod_version=4.1.1', 'mod_version=4.1.2')], + ['wrong loader', properties.replace('neoforge', 'forge')], + ['unsupported loader', properties.replace('neoforge', 'fabric')], + ['wrong Minecraft version', properties.replace('1.21.1', '1.21.11')], + ['wrong CurseForge project', properties.replace('245586', '123')], +]) test(`reject ${label}`, () => assert.throws(() => releaseMetadata(metadata.version, changed))); + +test('checksum entries require the exact filename and cannot be missing or duplicated', () => { + const hash = 'aB'.repeat(32); + assert.equal(checksumFor(`${hash} main.jar\r\n`, 'main.jar'), hash.toLowerCase()); + assert.equal(checksumFor(`${hash} *main.jar\n`, 'main.jar'), hash.toLowerCase()); + assert.throws(() => checksumFor(`${hash} wrong.jar`, 'main.jar')); + assert.throws(() => checksumFor(`${hash} main.jar\n${hash} main.jar`, 'main.jar')); +}); + +test('identical public uploads are reused and duplicate version numbers are rejected', () => { + assert.equal(matchingVersion([existing], metadata, hashes).id, 'existing'); + assert.equal(matchingVersion([], metadata, hashes), undefined); + assert.throws(() => matchingVersion([existing, existing], metadata, hashes)); +}); + +for (const [label, change] of [ + ['project', value => { value.project_id = 'another'; }], + ['status', value => { value.status = 'unlisted'; }], + ['Minecraft version', value => { value.game_versions = ['1.20.1']; }], + ['loader', value => { value.loaders = ['forge']; }], + ['release channel', value => { value.version_type = 'alpha'; }], + ['dependencies', value => { value.dependencies = [{ project_id: 'another', dependency_type: 'required' }]; }], + ['file set', value => { value.files.pop(); }], + ['hash', value => { value.files[0].hashes.sha512 = 'different'; }], + ['size', value => { value.files[0].size++; }], + ['primary file', value => { value.files[1].primary = true; }], +]) test(`stop rather than replace an existing upload with a conflicting ${label}`, () => { + const changed = structuredClone(existing); + change(changed); + assert.throws(() => matchingVersion([changed], metadata, hashes)); +}); + +test('duplicate protection uses the direct version endpoint and does not treat an API error as absence', async () => { + const request = async (url, options) => { + assert.equal(url, 'https://api.modrinth.com/v2/project/cXWN0TpD/version/4.1.1.121012'); + assert.equal(options.allowNotFound, true); + return existing; + }; + assert.equal((await findExistingVersion(metadata, hashes, request)).id, 'existing'); + assert.equal(await findExistingVersion(metadata, hashes, async () => undefined), undefined); + await assert.rejects(findExistingVersion(metadata, hashes, async () => { throw new Error('HTTP 503'); }), /HTTP 503/); +}); + +test('require an exact public CurseForge release with the matching loader, game and size', () => { + const file = { id: 123, url: 'https://www.curseforge.com/example', name: metadata.files[0], type: 'release', filesize: 42, versions: ['1.21.1', 'NeoForge'] }; + assert.deepEqual(publicCurseForgeFile([file], metadata, 42), { id: 123, url: file.url }); + assert.throws(() => publicCurseForgeFile([], metadata, 42)); + assert.throws(() => publicCurseForgeFile([file, file], metadata, 42)); + assert.throws(() => publicCurseForgeFile([{ ...file, type: 'beta' }], metadata, 42)); + assert.throws(() => publicCurseForgeFile([file], metadata, 43)); + assert.throws(() => publicCurseForgeFile([{ ...file, versions: ['1.20.1', 'NeoForge'] }], metadata, 42)); + assert.throws(() => publicCurseForgeFile([{ ...file, versions: ['1.21.1', 'Forge'] }], metadata, 42)); + assert.throws(() => publicCurseForgeFile([{ ...file, versions: ['1.21.1', 'Forge', 'NeoForge'] }], metadata, 42)); +}); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fc461d3..af332084 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,16 @@ name: CI -on: [push, pull_request] +on: + push: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' + pull_request: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' #on: # push: # branches: [ master-1.12 ] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index d5a02752..0b0b9ea1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -11,7 +11,17 @@ # name: "CodeQL" -on: [push, pull_request] +on: + push: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' + pull_request: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' #on: # push: # branches: [ master-1.12 ] diff --git a/.github/workflows/modrinth-checks.yml b/.github/workflows/modrinth-checks.yml new file mode 100644 index 00000000..36ebeb31 --- /dev/null +++ b/.github/workflows/modrinth-checks.yml @@ -0,0 +1,23 @@ +name: Modrinth publishing checks + +on: + push: + paths: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + pull_request: + paths: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + +permissions: + contents: read + +jobs: + test: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Test release selection, metadata, checksums and duplicate protection + run: node --test .github/scripts/modrinth-release.test.mjs diff --git a/.github/workflows/publish-modrinth.yml b/.github/workflows/publish-modrinth.yml new file mode 100644 index 00000000..406c071a --- /dev/null +++ b/.github/workflows/publish-modrinth.yml @@ -0,0 +1,89 @@ +name: Copy published OreSpawn releases to Modrinth + +run-name: Copy OreSpawn ${{ inputs.release_version }} to Modrinth + +on: + workflow_dispatch: + inputs: + release_version: + description: Published version, or latest-published for the latest release of each Minecraft version and loader. + required: true + type: string + confirm_live_publication: + description: Confirm copying the published files to Modrinth. Nothing is rebuilt or republished elsewhere. + required: true + default: false + type: boolean + +permissions: + contents: read + +jobs: + select: + if: github.repository == 'MinecraftModDevelopmentMods/OreSpawn' && inputs.confirm_live_publication + runs-on: ubuntu-latest + timeout-minutes: 10 + outputs: + versions: ${{ steps.select.outputs.versions }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - id: select + name: Select published releases + env: + GH_TOKEN: ${{ github.token }} + RELEASE_VERSION: ${{ inputs.release_version }} + run: node .github/scripts/modrinth-release.mjs select + + publish: + name: Copy ${{ matrix.version }} + needs: select + runs-on: ubuntu-latest + timeout-minutes: 20 + strategy: + fail-fast: false + max-parallel: 3 + matrix: + version: ${{ fromJSON(needs.select.outputs.versions) }} + concurrency: + group: orespawn-modrinth-${{ matrix.version }} + cancel-in-progress: false + env: + GH_TOKEN: ${{ github.token }} + RELEASE_VERSION: ${{ matrix.version }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Verify published files and check for an existing upload + id: prepare + run: node .github/scripts/modrinth-release.mjs prepare + - name: Copy release to Modrinth + id: publish + if: steps.prepare.outputs.publish == 'true' + uses: Kira-NT/mc-publish@52307b03863581dec6b652b83e597aec02ebb075 # v3.3.1 + with: + modrinth-id: cXWN0TpD + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + modrinth-featured: false + modrinth-unfeature-mode: none + modrinth-retry-attempts: 1 + name: ${{ steps.prepare.outputs.name }} + version: ${{ matrix.version }} + version-type: release + changelog-file: ${{ runner.temp }}/release-input/CHANGELOG.md + loaders: ${{ steps.prepare.outputs.loader }} + game-versions: ${{ steps.prepare.outputs.minecraft }} + game-version-filter: none + environment: client | server + files: ${{ steps.prepare.outputs.files }} + fail-mode: fail + - name: Verify public downloads against the original checksums + env: + MODRINTH_VERSION: ${{ steps.publish.outputs.modrinth-version || steps.prepare.outputs.existing_version }} + run: node .github/scripts/modrinth-release.mjs verify + - name: Save publication receipt + if: always() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: modrinth-${{ matrix.version }}-${{ github.run_attempt }} + path: ${{ runner.temp }}/release-input/modrinth-receipt.json + if-no-files-found: warn + retention-days: 90 diff --git a/.github/workflows/validate-gradle-build.yml b/.github/workflows/validate-gradle-build.yml index 528f4b5a..107975f3 100644 --- a/.github/workflows/validate-gradle-build.yml +++ b/.github/workflows/validate-gradle-build.yml @@ -1,6 +1,16 @@ name: Validate Gradle Wrapper -on: [push, pull_request] +on: + push: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' + pull_request: + paths-ignore: + - '.github/scripts/modrinth-*' + - '.github/workflows/*modrinth*' + - '.github/MODRINTH.md' jobs: validation: