Skip to content

Commit

Permalink
Add script to announce snapshot ports after publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Jan 22, 2025
1 parent 15b4c7f commit 4a5e251
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/publish_snapshot_ports.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ on:
type: boolean
required: false
default: true
announce:
description: "Announce the snapshot port(s) on WurstForum"
type: boolean
required: false
default: true


jobs:

Expand Down Expand Up @@ -142,3 +148,16 @@ jobs:
repo: Mo-Glass
run_id: ${{ steps.mo_glass_dispatch.outputs.run_id }}
run_timeout_seconds: 600 # 10 minutes

announce:
runs-on: ubuntu-latest
needs: [wurst, wi_zoom, mo_glass]
if: ${{ !failure() && !cancelled() && inputs.announce }}
steps:
- name: Announce snapshot ports
run: |
python3 scripts/announce_snapshot_ports.py \
${{ github.event.inputs.snapshot }} \
${{ inputs.include_wurst && 'wurst7' || '' }} \
${{ inputs.include_wi_zoom && 'wi-zoom' || '' }} \
${{ inputs.include_mo_glass && 'mo-glass' || '' }}
46 changes: 46 additions & 0 deletions scripts/announce_snapshot_ports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import util
from argparse import ArgumentParser
from pathlib import Path

current_snapshot_discussion = 953


def get_link(mod: str, branch: str) -> str:
props = util.read_gradle_properties(mod, branch)
version = props["mod_version"].removeprefix("v")
version = version[: version.index("-MC")]

if mod == "wurst7":
return f"https://www.wurstclient.net/updates/wurst-{version.replace('.', '-')}?mc={branch}"
else:
return f"https://www.wimods.net/{mod}/{mod}-{version.replace('.', '-')}?mc={branch}"


def main(snapshot: str, included_mods: list[str], dry_run: bool):
config = util.read_toml_file(Path("config.toml"))
possible_mod_names = config["Params"]["modnames"]
possible_mod_names["wurst7"] = "Wurst"
mod_names = [possible_mod_names[mod] for mod in included_mods]

if len(included_mods) == 1:
mods_string = mod_names[0]
else:
mods_string = f"{', '.join(mod_names[:-1])} and {mod_names[-1]}"
content = f"{mods_string} {'has' if len(included_mods) == 1 else 'have'} been updated to support Minecraft {snapshot}!\n\n"

for mod in included_mods:
content += f"{possible_mod_names[mod]}: <{get_link(mod, snapshot)}>\n"
content += "\nEnjoy! 🤖"

util.upload_post(current_snapshot_discussion, content, dry_run=dry_run)


if __name__ == "__main__":
parser = ArgumentParser(description="Announces a new mod update on WurstForum")
parser.add_argument("snapshot", help="Snapshot branch name (e.g. '25w03a')")
parser.add_argument("mods", nargs="+", help="Mods to include in the announcement")
parser.add_argument(
"--dry-run", action="store_true", help="Don't actually upload the announcement"
)
args = parser.parse_args()
main(args.snapshot, args.mods, args.dry_run)

0 comments on commit 4a5e251

Please sign in to comment.