Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b2b9f7d
Create publish step for each distribution site
SpecialBuilder32 Sep 4, 2026
f7702b4
Add final summarize step
SpecialBuilder32 Sep 4, 2026
936db09
Framework for loading partial beet.yaml data for the publish pipeline
SpecialBuilder32 Sep 6, 2026
c8ea087
Send .beet_cache between build and publish jobs
SpecialBuilder32 Sep 6, 2026
0deb5ab
Move publish plugins to new file
SpecialBuilder32 Sep 6, 2026
195df2b
Only run the right publish pipeline for each workflow job
SpecialBuilder32 Sep 6, 2026
349dd37
Better logging for invalid tokens
SpecialBuilder32 Sep 6, 2026
f5b7f37
Aggregate logs from all jobs to form github summary
SpecialBuilder32 Sep 7, 2026
c151665
Cleanup action debug print statements
SpecialBuilder32 Sep 8, 2026
8710727
Include libraries in publish for smithed
SpecialBuilder32 Sep 8, 2026
d333db5
Intra-job artifacts expire after 2 days
SpecialBuilder32 Sep 13, 2026
31f8ad9
Use meta.json with PRs to preview version patch changes
SpecialBuilder32 Sep 13, 2026
cb0a8df
Allow logging to mark action failed without sys.exit
SpecialBuilder32 Sep 13, 2026
e46f5f5
Transfer zips to publish via artifact for better idempotency
SpecialBuilder32 Sep 21, 2026
9813df7
Use short commit hash for artifact name
SpecialBuilder32 Sep 21, 2026
eba9a56
Replace && || with clearer 'case()' expressions
SpecialBuilder32 Sep 21, 2026
ee2a456
Restore publish concurrency limits
SpecialBuilder32 Sep 22, 2026
ca374ea
Update ENV fallback for 26.3
SpecialBuilder32 Sep 22, 2026
382080b
Merge branch 'master' into split-publish-action
SpecialBuilder32 Sep 22, 2026
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
111 changes: 103 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ jobs:
build:
runs-on: ubuntu-24.04
concurrency:
group: ${{ github.event_name != 'pull_request' && 'release' || format('pr-{0}', github.event.number) }}
group: ${{ case(github.event_name != 'pull_request', 'release', format('pr-{0}', github.event.number)) }}
steps:
- uses: actions/checkout@v7

- name: Checkout release branch
if: github.event_name != 'pull_request'
uses: actions/checkout@v7
with:
ref: release
Expand All @@ -38,14 +37,14 @@ jobs:
env:
BEET_MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
BEET_SMITHED_TOKEN: ${{ secrets.SMITHED_TOKEN }}
LOG_LEVEL: ${{ runner.debug == 1 && 'DEBUG' || 'INFO'}}
LOG_LEVEL: ${{ case(runner.debug == 1, 'DEBUG', 'INFO') }}
MASTER_BUILD: true

- name: Build all modules for pull request
if: github.event_name == 'pull_request'
run: uv run beet -p beet-release.yaml -l ${{ env.LOG_LEVEL }} build
env:
LOG_LEVEL: ${{ runner.debug == 1 && 'DEBUG' || 'INFO'}}
LOG_LEVEL: ${{ case(runner.debug == 1, 'DEBUG', 'INFO') }}

- name: Remove non-modules for artifact
if: github.event_name == 'pull_request'
Expand All @@ -54,11 +53,15 @@ jobs:
rm release/$VERSION/lib_*
rm release/$VERSION/meta.json

- name: Upload artifact
if: github.event_name == 'pull_request'
- name: Retrieve commit sha
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV

- name: Upload zip artifact
uses: actions/upload-artifact@v7
with:
name: 'Modules for pull request #${{ github.event.number }}'
name: "${{ format('Modules for {0} #{1}', \
case(github.event_name != 'pull_request', 'publish', 'pull request'),\
case(github.event_name != 'pull_request', env.SHORT_SHA, github.event.number)) }}"
path: ${{ github.workspace }}/release/${{ env.VERSION }}/

- name: Commit release
Expand All @@ -78,6 +81,24 @@ jobs:
directory: release
branch: release

- name: Upload .beet_cache as artifact
uses: actions/upload-artifact@v7
with:
name: .beet_cache
path: ${{ github.workspace }}/.beet_cache/
include-hidden-files: true
retention-days: 2

- name: Rename log file
run: mv ${{ github.workspace }}/logs/summary_logs.pkl ${{ github.workspace }}/logs/build_log.pkl

- name: Upload logs as artifact
uses: actions/upload-artifact@v7
with:
path: ${{ github.workspace }}/logs/build_log.pkl
archive: false
retention-days: 2

test:
strategy:
fail-fast: false
Expand All @@ -102,7 +123,7 @@ jobs:
- name: Build all modules for tests
run: uv run beet -p beet-test.yaml -l ${{ env.LOG_LEVEL }} build
env:
LOG_LEVEL: ${{ runner.debug == 1 && 'DEBUG' || 'INFO'}}
LOG_LEVEL: ${{ case(runner.debug == 1, 'DEBUG', 'INFO') }}

- name: Setup Java
uses: actions/setup-java@v6
Expand Down Expand Up @@ -135,3 +156,77 @@ jobs:
with:
name: 'Test world in ${{ matrix.version }} for ${{ github.sha }}'
path: ${{ github.workspace }}/world/

publish:
runs-on: ubuntu-24.04
if: github.event_name != 'pull_request'
needs: build
strategy:
matrix:
platform: [modrinth, smithed]
concurrency:
group: 'publish-${{ matrix.platform }}'
name: 'publish'
steps:
- uses: actions/checkout@v7

- name: Retrieve commit sha
run: echo "SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV

- name: Download module zips from artifact
uses: actions/download-artifact@v7
with:
name: 'Modules for publish #${{ env.SHORT_SHA }}'
path: ${{ github.workspace }}/release/${{ env.VERSION }}/

- name: Restore .beet_cache from artifact
uses: actions/download-artifact@v7
with:
name: .beet_cache
path: ${{ github.workspace }}/.beet_cache

- name: Set up uv
uses: astral-sh/setup-uv@v7

- name: Publish all modules
run: uv run beet -p beet-publish.yaml -l ${{ env.LOG_LEVEL }} -s meta.gm4.publish_to=${{ matrix.platform }} build
env:
BEET_MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
BEET_SMITHED_TOKEN: ${{ secrets.SMITHED_TOKEN }}
LOG_LEVEL: ${{ case(runner.debug == 1, 'DEBUG', 'INFO') }}

- name: Rename log file
run: mv ${{ github.workspace }}/logs/summary_logs.pkl ${{ github.workspace }}/logs/publish_${{ matrix.platform }}_log.pkl

- name: Upload logs as artifact
uses: actions/upload-artifact@v7
with:
path: ${{ github.workspace }}/logs/publish_${{ matrix.platform }}_log.pkl
archive: false
retention-days: 2

summarize:
runs-on: ubuntu-24.04
needs: [build, publish]
if: ${{ always() }}
steps:
- uses: actions/checkout@v7

- name: Restore .beet_cache from artifact
uses: actions/download-artifact@v7
with:
name: .beet_cache
path: ${{ github.workspace }}/.beet_cache

- name: Restore log files from artifacts
uses: actions/download-artifact@v8
with:
pattern: '*_log.pkl'
path: ${{ github.workspace }}/logs
merge-multiple: true

- name: Set up uv
uses: astral-sh/setup-uv@v7

- name: Summarize build logs
run: uv run beet -p beet-summarize.yaml -s meta.gm4.summarize_type=${{ case(github.event_name != 'pull_request', 'release', 'pull_request') }} build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ __pycache__/
### Beet ###
out/
release/
logs/
.beet_cache/
12 changes: 12 additions & 0 deletions beet-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pipeline:
- gm4.plugins.publish.check_gh_action_failed
- gm4.plugins.annotations
- gm4.plugins.publish.switch_platform

- broadcast: [gm4_*, lib_*]
pipeline:
- gm4.plugins.publish.load_config
meta:
plugins:
- gm4.plugins.readme_generator
- gm4.plugins.publish
2 changes: 2 additions & 0 deletions beet-summarize.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pipeline:
- gm4.plugins.annotations.load_and_summarize
40 changes: 35 additions & 5 deletions gm4/plugins/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from functools import partial
from pathlib import Path
from typing import Any
import pickle

from beet import Context, ProjectCache

Expand All @@ -31,12 +32,32 @@ def filter(record: logging.LogRecord):

# summary handler holds onto certain records until the exit phase when it emits to a markdown summary
sum_handler = SummaryHandler(1000, ctx.cache)
logging.getLogger("gm4.output").addHandler(sum_handler)
logging.getLogger("gm4.publish").addHandler(sum_handler)
logging.getLogger("gm4.manifest.update_patch").addHandler(sum_handler)

# after the whole build, flush the stored records and form the markdown summary
# after the whole build, flush the stored records to file for the later markdown summary action job
yield
sum_handler.flush()
sum_handler.flush_to_pickle()

def load_and_summarize(ctx: Context):
"""Loads log entries from previous gh step/job to aggregate"""
sum_handler = SummaryHandler(1000, ctx.cache)

log_dir = Path("logs")
for log_file in log_dir.iterdir():
with open(log_file, 'rb') as f:
log_buffer: list[logging.LogRecord] = pickle.load(f)
for log_entry in log_buffer:
sum_handler.emit(log_entry)

summary_title = ""
if (sum_type:=ctx.meta.get('gm4', {}).get('summarize_type')) == 'release':
summary_title = "Build Deployment Summary"
elif sum_type == 'pull_request':
summary_title = "Pull Request Deployment Preview"

sum_handler.flush_to_summary(summary_title)


LEVEL_CONVERSION = {
logging.DEBUG: "debug",
Expand Down Expand Up @@ -85,7 +106,7 @@ def __init__(self, capacity: int, beet_cache: ProjectCache):
self.beet_cache = beet_cache
self.summary_created = False

def flush(self):
def flush_to_summary(self, summary_title: str):
summary_entries: dict[str, Any] = {}

this_manifest = ManifestCacheModel.model_validate(self.beet_cache["gm4_manifest"].json)
Expand Down Expand Up @@ -131,7 +152,7 @@ def flush(self):

table += f"\n {entry['name']} | {entry['ver_update']} | {nested_table}"

summary = "# :rocket: Build Deployment Summary :rocket:\n"+table
summary = f"# :rocket: {summary_title} :rocket:\n"+table

if not self.summary_created:
env_file = os.getenv("GITHUB_STEP_SUMMARY")
Expand All @@ -141,6 +162,15 @@ def flush(self):
self.summary_created = True
self.buffer.clear()

def flush_to_pickle(self):
"""Writes buffer of log entries to file, for a later gh action step to aggregate into the summary file"""
log_dir = Path("logs")
log_file = log_dir/"summary_logs.pkl"
os.makedirs(log_dir, exist_ok=True)
with open(log_file, "wb") as f:
pickle.dump(self.buffer, f)
self.buffer.clear()



def add_module_dir_to_diagnostics(ctx: Context):
Expand Down
Loading
Loading