diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f5c183b..cc44ed7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,6 +14,17 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 # needed for versioning + # Keep the branch patterns here (main, releases/**) in sync with the `if:` conditions on the + # three publish steps below - each encodes the same restriction independently. + - name: Verify branch is allowed to publish + if: startsWith(github.ref, 'refs/heads/') + env: + REF_NAME: ${{ github.ref_name }} + run: | + if [ "$REF_NAME" != "main" ] && [[ "$REF_NAME" != releases/* ]]; then + echo "::error::Publishing is only permitted from main or releases/** branches (got '$REF_NAME')" + exit 1 + fi - name: Set up JDK 25 uses: actions/setup-java@v5 with: @@ -34,11 +45,18 @@ jobs: - name: summarize test results if: always() uses: ./.github/actions/summarize-test-results + # Branch pattern here must stay in sync with the guard step and the two publish steps below. - name: Publish alpha to Modrinth - if: startsWith(github.ref, 'refs/heads/') + if: github.ref == 'refs/heads/main' env: MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} run: ./gradlew modrinth -PbuildNumber=${{ github.run_number }} + # Branch pattern here must stay in sync with the guard step and the other two publish steps. + - name: Publish beta to Modrinth + if: startsWith(github.ref, 'refs/heads/releases/') + env: + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + run: ./gradlew modrinth -PbuildNumber=${{ github.run_number }} -PisBeta - name: Publish release to Modrinth if: startsWith(github.ref, 'refs/tags/') env: diff --git a/AGENTS.md b/AGENTS.md index f4d30c4..2393075 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -32,8 +32,10 @@ values there, not in `build.gradle`. `mod_version` follows `- CI (`.github/workflows/build.yml`) runs the unit tests and then `./gradlew build` on push/PR to `main` and `releases/**`; either failing fails the job. `.github/workflows/publish.yml` is manually dispatched, also runs the -unit tests first (a failure blocks publishing), then runs `./gradlew modrinth` to publish to Modrinth (alpha from -branch dispatch, release from a `v*` tag dispatch with `-PisRelease`). +unit tests first (a failure blocks publishing), then runs `./gradlew modrinth` to publish to Modrinth: `main` branch +dispatch → alpha, `releases/**` branch dispatch → beta (`-PisBeta`), `v*` tag dispatch → release (`-PisRelease`, +exempt from the branch restriction below). A guard step run before the unit tests fails the job outright if a +branch dispatch targets anything other than `main` or `releases/**`. Both workflows also have a `summarize test results` step right after `run unit tests` (`if: always()`, so it still runs when tests fail). It sums the `tests`/`failures`/`errors`/`skipped` attributes out of Gradle's JUnit XML reports diff --git a/agent-context/context/architecture.md b/agent-context/context/architecture.md index d872c5f..e7c52fa 100644 --- a/agent-context/context/architecture.md +++ b/agent-context/context/architecture.md @@ -74,10 +74,12 @@ dev source for `runServer`/`runClient`. XML results to `$GITHUB_STEP_SUMMARY` via the shared composite action `.github/actions/summarize-test-results/` (plain shell `sed`, no third-party reporter action — see `testing.md` for why) → `./gradlew build` → upload `build/libs/` as an artifact -- `.github/workflows/publish.yml` — manual `workflow_dispatch` only: runs tests first (failure blocks publish), then - `./gradlew modrinth -PbuildNumber=` (alpha, from a branch dispatch) or the same with `-PisRelease` +- `.github/workflows/publish.yml` — manual `workflow_dispatch` only: a guard step (before tests) fails the job if a + branch dispatch targets anything other than `main` or `releases/**` (tag dispatches are exempt); tests then run + (failure blocks publish); then `./gradlew modrinth -PbuildNumber=` (alpha, from a `main` branch + dispatch), the same with `-PisBeta` (beta, from a `releases/**` branch dispatch), or the same with `-PisRelease` (release, from a `v*` tag dispatch) --- -*Last updated: 2026-09-11 | Verified against: feature/tpwalke2/209-actionfactory (5eb0f1d)* +*Last updated: 2026-09-12 | Verified against: main (3cba636, plus uncommitted publish.yml/build.gradle beta-publish changes)* diff --git a/build.gradle b/build.gradle index 82b78ca..1742948 100644 --- a/build.gradle +++ b/build.gradle @@ -95,6 +95,9 @@ modrinth { version = version = "${project.mod_version}.${project.findProperty('buildNumber')}" versionType = "release" changelog.set("Releasenotes and Changelog:\\nhttps://github.com/tpwalke2/BlueMapSignMarkers/releases/tag/v${project.mod_version}") + } else if (project.hasProperty('isBeta')) { + version = "${project.mod_version}.${project.findProperty('buildNumber')}-beta" + versionType = "beta" } else { version = "${project.mod_version}.${project.findProperty('buildNumber')}-alpha" versionType = "alpha"