🚀 continuous_delivery#
Publishing a project to GitHub, Modrinth, Smithed and PlanetMinecraft.
cd_utils#
github#
modrinth#
- MOD_PLATFORMS: list[str] = ['fabric', 'forge', 'neoforge', 'quilt'][source]#
Every platform a datapack is packaged as a mod for, unless
mod_platformsnames some.
- PROJECT_FALLBACKS: tuple[tuple[str, str], ...] = (('description', 'description'), ('homepage', 'project_url'), ('sources', 'source_url'), ('issues', 'issues_url'))[source]#
Mod metadata a Modrinth project field fills when the config leaves it empty.
- validate_credentials(credentials: dict[str, str]) str[source]#
Get and validate Modrinth credentials
- Parameters:
credentials – Credentials for the Modrinth API
- Returns:
API key for Modrinth
- Return type:
str
- validate_config(
- modrinth_config: JsonDict,
Validate Modrinth configuration
- Parameters:
modrinth_config – Configuration for the Modrinth project
- Returns:
Project name on Modrinth str: Version of the project str: Slug (namespace) of the project str: Summary of the project str: Description in Markdown format str: Version type (release, beta, alpha) str: Build folder path
- Return type:
str
- get_project(
- slug: str,
- headers: dict[str, str],
Get project from Modrinth
- Parameters:
slug – Project slug/namespace
headers – Headers for Modrinth API requests
- Returns:
Project data
- Return type:
dict
- update_project_description(
- slug: str,
- description: str,
- summary: str,
- headers: dict[str, str],
Update project description and summary
- Parameters:
slug – Project slug/namespace
description – Project description in Markdown
summary – Project summary
headers – Headers for Modrinth API requests
- handle_existing_version(
- slug: str,
- version: str,
- headers: dict[str, str],
Check and handle existing version
- Parameters:
slug – Project slug/namespace
version – Version to check
headers – Headers for Modrinth API requests
- Returns:
True if we should continue, False otherwise
- Return type:
bool
- generate_fabric_metadata(
- mod_id: str,
- metadata: JsonDict,
Generate Fabric mod metadata JSON
- Parameters:
mod_id – Mod ID
metadata – Mod metadata
- Returns:
Fabric mod.json content
- Return type:
str
- generate_forge_metadata(
- mod_id: str,
- metadata: JsonDict,
- is_neoforge: bool = False,
Generate Forge/NeoForge mod metadata TOML
- Parameters:
mod_id – Mod ID
metadata – Mod metadata
is_neoforge – Whether this is for NeoForge (uses javafml) or Forge (uses lowcodefml)
- Returns:
mods.toml content
- Return type:
str
- generate_quilt_metadata(
- mod_id: str,
- metadata: JsonDict,
Generate Quilt mod metadata JSON
- Parameters:
mod_id – Mod ID
metadata – Mod metadata
- Returns:
quilt.mod.json content
- Return type:
str
- convert_datapack_to_mod(
- datapack_path: str,
- output_path: str,
- metadata: JsonDict,
- platforms: list[str],
- resource_pack_path: str | None = None,
Convert a datapack ZIP to a mod JAR with proper metadata files
- Parameters:
datapack_path – Path to the datapack ZIP file
output_path – Path where to save the mod JAR file
metadata – Mod metadata (id, name, version, description, authors, etc.)
platforms – List of platforms (fabric, forge, neoforge, quilt)
resource_pack_path – Optional path to the resource pack ZIP file
- get_file_parts(
- project_name: str,
- build_folder: str,
- modrinth_config: JsonDict,
- project_data: JsonDict | None = None,
Get file parts to upload
- Parameters:
project_name – Name of the project
build_folder – Path to build folder
modrinth_config – Modrinth configuration
project_data – Optional project data from Modrinth API
- Returns:
List of file paths to upload
- Return type:
list[str]
- explicit_files(
- modrinth_config: JsonDict,
The
filesof the config, to upload instead of the build folder’s packs. Empty when not configured.Their names contain
datapackandresource_pack, the datapack listed first.- Raises:
FileNotFoundError – When a configured file does not exist.
ValueError – When
filesis configured but empty.
- existing_packs(
- project_name: str,
- build_folder: str,
The datapack and resource pack zips of the build, bundled with their libraries when it made those.
- Raises:
ValueError – When the build folder holds neither.
- mod_platforms(
- modrinth_config: JsonDict,
The platforms to package the mod for,
mod_platformsbeing one name or a list of them.
- mod_metadata(
- project_name: str,
- modrinth_config: JsonDict,
- project_data: JsonDict | None,
The mod’s metadata from the config, completed by the Modrinth project, whose title also names the mod.
- upload_version(
- project_id: str,
- project_name: str,
- version: str,
- version_type: str,
- changelog: str,
- file_parts: list[str],
- headers: dict[str, str],
- dependencies: list[str] | None = None,
- loaders: list[str] | None = None,
Upload new version
- Parameters:
project_id – Modrinth project ID
project_name – Name of the project
version – Version number
version_type – Type of version (release, beta, alpha)
changelog – Changelog text
file_parts – List of files to upload
headers – Headers for Modrinth API requests
dependencies – List of dependencies
loaders – List of loaders (datapack, fabric, forge, etc.)
- Returns:
Upload response data
- Return type:
dict
- set_resource_pack_required(
- version_id: str,
- resource_pack_hash: str,
- headers: dict[str, str],
Set resource pack as required
- Parameters:
version_id – ID of the version
resource_pack_hash – SHA1 hash of resource pack
headers – Headers for Modrinth API requests
- upload_to_modrinth(
- credentials: dict[str, str],
- modrinth_config: JsonDict,
- changelog: str = '',
Upload the project to Modrinth using the credentials and the configuration
- Parameters:
credentials – Credentials for the Modrinth API
modrinth_config – Configuration for the Modrinth project
changelog – Changelog text for the release
- upload_mods(
- release: Release,
- slug: str,
- version: str,
- file_parts: list[str],
- every_platform: bool,
- platforms: list[str],
Upload the mod as one version for all platforms (
<version>+mod), or one per platform (<version>+<platform>).
- class Release(
- project_id: str,
- project_name: str,
- version_type: str,
- changelog: str,
- headers: dict[str, str],
- dependencies: list[str],
Bases:
objectWhat every version uploaded for one release of a project shares.
pmc#
- validate_config(pmc_config: dict[str, str]) str[source]#
Validate PlanetMinecraft configuration
- Parameters:
pmc_config – Configuration for the PlanetMinecraft project
- Returns:
Project url on PlanetMinecraft
- Return type:
str
- table_to_bbcode(match: Match[str]) str[source]#
Convert a markdown table match to BBCode format
- Parameters:
match – Regex match object containing a markdown table block
- Returns:
BBCode table string
- Return type:
str
- convert_list_block(
- block_lines: list[str],
- list_type: str = '',
Convert a block of markdown list lines (with possible nesting) to BBCode
- Parameters:
block_lines – Lines of the list block
list_type – BBCode list type: ‘’ for unordered, ‘1’ for numbered, ‘a’ for alphabetical
- Returns:
BBCode list string
- Return type:
str
- follow_indent(
- result: list[str],
- level_stack: list[int],
- indent: int,
- open_tag: str,
Open a nested list where an item indents deeper than the last, and close those it dedents out of.
- Parameters:
result – BBCode lines so far, appended to.
level_stack – Indentation of each open list, outermost first, updated.
- convert_markdown_to_bbcode(
- markdown: str,
- verbose: bool = True,
Convert markdown to the bbcode PlanetMinecraft descriptions use.
- Parameters:
verbose – If True, print the conversion comparison
>>> print(convert_markdown_to_bbcode('~~strikethrough~~', verbose=False)) [s]strikethrough[/s] >>> print(convert_markdown_to_bbcode('1. item 1\n2. item 2', verbose=False)) [list=1] [*]item 1[/*] [*]item 2[/*] [/list]
- upload_version(project_url: str, changelog: str) None[source]#
Upload new version by opening the project url with the browser
- Parameters:
project_url – Url of the project on PlanetMinecraft to open
changelog – Changelog text
- upload_to_pmc(
- pmc_config: JsonDict,
- changelog: str = '',
Upload the project to PlanetMinecraft using the configuration
- Disclaimer:
There is no API for PlanetMinecraft, so everything is done manually.
- Parameters:
pmc_config – Configuration for the PlanetMinecraft project
changelog – Changelog text for the release
smithed#
- validate_credentials(
- credentials: JsonDict,
Get and validate Smithed credentials
- Parameters:
credentials – Credentials for the Smithed API
- Returns:
API key for Smithed str: GitHub author
- Return type:
str
- validate_config(
- smithed_config: dict[str, Any],
Validate Smithed configuration
- Parameters:
smithed_config – Configuration for the Smithed project
- Returns:
Project name on Smithed str: Version of the project str: Slug (namespace) of the project
- Return type:
str
- upload_version(
- project_id: str,
- project_name: str,
- version: str,
- api_key: str,
- author: str,
- files: dict[str, str] | None = None,
- github_project_name: str | None = None,
Upload new version
- Parameters:
project_id – Smithed project ID
project_name – Name of the project
version – Version number
api_key – API key for Smithed
author – Author (for the github link)
files – Local ‘datapack’ and optional ‘resourcepack’ zips, already uploaded to the GitHub release
github_project_name – GitHub repository name, if different from project_name
- upload_to_smithed(
- credentials: dict[str, str],
- smithed_config: dict[str, Any],
- changelog: str = '',
Upload the project to Smithed using the credentials and the configuration
- Parameters:
credentials – Credentials for the Smithed API
smithed_config – Configuration for the Smithed project
changelog – Changelog text for the release