Skip to content
Open
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
106 changes: 106 additions & 0 deletions .github/workflows/publish-workshop-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Publish Workshop build

on:
push:
branches: [workshop]
workflow_dispatch:

permissions:
contents: write

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Validate Workshop build first
shell: bash
run: |
set -euo pipefail
test -f metamorph_creative_menu/mod.xml
test -f metamorph_creative_menu/mod_id.txt
test -f metamorph_creative_menu/init.lua
test -f metamorph_creative_menu/workshop.xml
test -f metamorph_creative_menu/workshop_preview_image.png
test ! -d metamorph_creative_menu/NoitaPatcher
if find metamorph_creative_menu -type f -iname '*.dll' | grep -q .; then
echo 'Workshop package contains a DLL' >&2
exit 1
fi
if grep -q 'request_no_api_restrictions' metamorph_creative_menu/mod.xml; then
echo 'Workshop mod.xml requests unrestricted API' >&2
exit 1
fi

- name: Package ready-to-upload Workshop mod
shell: bash
run: |
set -euo pipefail
rm -rf dist
mkdir -p dist/metamorph_creative_menu
cp -a metamorph_creative_menu/. dist/metamorph_creative_menu/
rm -rf \
dist/metamorph_creative_menu/NoitaPatcher \
dist/metamorph_creative_menu/tests \
dist/metamorph_creative_menu/files/qa \
dist/metamorph_creative_menu/files/diagnostics
rm -f dist/metamorph_creative_menu/README.txt
(
cd dist
zip -qr ../Metamorph-Creative-Menu-Workshop.zip metamorph_creative_menu
)

python3 - <<'PY'
from pathlib import Path
import zipfile

archive = Path('Metamorph-Creative-Menu-Workshop.zip')
with zipfile.ZipFile(archive) as z:
names = set(z.namelist())
required = {
'metamorph_creative_menu/mod.xml',
'metamorph_creative_menu/mod_id.txt',
'metamorph_creative_menu/init.lua',
'metamorph_creative_menu/workshop.xml',
'metamorph_creative_menu/workshop_preview_image.png',
}
missing = sorted(required - names)
if missing:
raise SystemExit('Missing required files in Workshop ZIP: ' + ', '.join(missing))
forbidden = [
n for n in names
if n.lower().endswith('.dll')
or n.startswith('metamorph_creative_menu/NoitaPatcher/')
or n.startswith('metamorph_creative_menu/tests/')
or n.startswith('metamorph_creative_menu/files/qa/')
or n.startswith('metamorph_creative_menu/files/diagnostics/')
]
if forbidden:
raise SystemExit('Forbidden files in Workshop ZIP: ' + ', '.join(sorted(forbidden)))
print(f'Workshop ZIP: PASS bytes={archive.stat().st_size}')
PY

- name: Publish stable Workshop download
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
TAG=workshop-latest
ASSET=Metamorph-Creative-Menu-Workshop.zip

git tag -f "$TAG" "$GITHUB_SHA"
git push origin "refs/tags/$TAG" --force

if gh release view "$TAG" >/dev/null 2>&1; then
gh release edit "$TAG" \
--title "Latest Steam Workshop build" \
--notes "Ready-to-upload Steam Workshop edition. This build intentionally excludes bundled NoitaPatcher/DLL and unrestricted API access."
else
gh release create "$TAG" \
--title "Latest Steam Workshop build" \
--notes "Ready-to-upload Steam Workshop edition. This build intentionally excludes bundled NoitaPatcher/DLL and unrestricted API access."
fi

gh release upload "$TAG" "$ASSET" --clobber
70 changes: 70 additions & 0 deletions .github/workflows/replace-workshop-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Replace Workshop preview

on:
push:
branches: [workshop]

permissions:
contents: write

jobs:
replace-preview:
if: github.event.head_commit.message == 'Stage corrected Workshop preview'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build the correct Workshop preview from the accepted MCM banner
shell: bash
run: |
set -euo pipefail
python3 -m pip install --quiet pillow
python3 - <<'PY'
from PIL import Image
from pathlib import Path

src = Path('assets/metamorph-creative-menu-banner.jpg')
out = Path('metamorph_creative_menu/workshop_preview_image.png')

img = Image.open(src).convert('RGB')
w, h = img.size

# The accepted Social Preview artwork is the centered 2:1 crop of the
# repository banner. Preserve that composition, then pad to Noita's
# 16:9 Workshop preview without stretching the title artwork.
target_ratio = 2.0
if w / h > target_ratio:
crop_w = int(round(h * target_ratio))
left = (w - crop_w) // 2
img = img.crop((left, 0, left + crop_w, h))
else:
crop_h = int(round(w / target_ratio))
top = (h - crop_h) // 2
img = img.crop((0, top, w, top + crop_h))

img = img.resize((1280, 640), Image.Resampling.LANCZOS)
canvas = Image.new('RGB', (1280, 720), (0, 0, 0))
canvas.paste(img, (0, 40))

# Indexed PNG keeps the Workshop preview compact while preserving the artwork.
preview = canvas.quantize(
colors=256,
method=Image.Quantize.MEDIANCUT,
dither=Image.Dither.FLOYDSTEINBERG,
)
preview.save(out, 'PNG', optimize=True, compress_level=9)
print(f'preview={out} size={out.stat().st_size} bytes')
PY

- name: Commit corrected preview and remove one-shot workflow
shell: bash
run: |
set -euo pipefail
rm -f .github/workflows/replace-workshop-preview.yml
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add metamorph_creative_menu/workshop_preview_image.png .github/workflows/replace-workshop-preview.yml
git commit -m "Use correct MCM artwork for Workshop preview"
git push origin HEAD:workshop
Loading
Loading