MCPInstall
build-mcpack-action logo

build-mcpack-action

by legopitstop legopitstop/build-mcpack-action

This action compiles your addon or pack into an installable file.

READMEmain

build mcpack action

This action compiles your addon or pack into an installable file.

Features

  • Customize the name of the generated artifact using patterns.
  • Automatically creates a contents.json file listing all files included in the pack.
  • Minifies all JSON files to reduce file size.
  • Handles behavior packs, resource packs, and skin packs.
  • Enable detailed logging for debugging purposes.

Usage

Your YML file in .github/workflows

name: Build and Publish MCPACK

on:
  # Run this workflow manually from the Actions tab
  workflow_dispatch:

permissions:
  packages: write
  contents: write
  id-token: write

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Bundle and create release.
        id: custom_action
        uses: legopitstop/build-mcpack-action@v1
        with:
          buildScript: "build.py"
          input: src/
          output: dist/
          outputPattern: "NAME_ABBR-VERSION.mcpack"

With a reposotry structed like:

📃build.py
📁src/
├── 📁behavior_pack/
│   └── 📃manifest.json
├── 📁resource_pack/
│   └── 📃manifest.json
└── 📁skin_pack/
    └── 📃manifest.json

Build Script

An example build script. This is where you can automate things like generating loot tables or recipes using Python with mcaddon.

# File: build.py
from argparse import ArgumentParser


def build():
    parser = ArgumentParser()
    parser.add_argument("--example", action="store_true")

    args = parser.parse_args()

    log.info("Starting pack build with args: %s", args)

    # Adds output.txt to behavior pack
    with open('behavior_pack/output.txt', 'w') as fd:
      fd.write('Hello, World!')

inputs

NameTypeDescription
buildScriptStringThe python script to build your addon, if any.
inputStringThe directory to look for packs.
outputStringThe directory to place the built artifacts
outputPatternStringThe name of the compiled file.

outputs

NameTypeDescription
packsStringJSON array containing the metadata of all bundled packs

Pack Metadata

NameTypeDescriptionExamples
uuidStringThe packs UUID
versionStringThe packs version
typeStringThe type of packbehavior, resource, skin
nameStringThe packs name
abbrStringThe abbreviated pack type.BP, RP, SP