diff --git a/.github/json/config-latest.json b/.github/json/config-latest.json index 0da2893..a882972 100644 --- a/.github/json/config-latest.json +++ b/.github/json/config-latest.json @@ -27,5 +27,5 @@ }, "max_pull_requests": 1000, "max_back_track_time_days": 365, - "base_branches": ["main"] + "base_branches": ["^main$", "^[0-9]+\\.x$"] } diff --git a/.github/json/config.json b/.github/json/config.json index 1a1a547..2554eca 100644 --- a/.github/json/config.json +++ b/.github/json/config.json @@ -37,5 +37,5 @@ }, "max_pull_requests": 1000, "max_back_track_time_days": 365, - "base_branches": ["main"] + "base_branches": ["^main$", "^[0-9]+\\.x$"] } diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml index b3148ae..05d91aa 100644 --- a/.github/workflows/auto-build.yml +++ b/.github/workflows/auto-build.yml @@ -2,7 +2,7 @@ name: Latest Build on: push: - branches: ['main'] + branches: ['main', '[0-9]+.x'] paths: ['**/src/**', '**/*.gradle', 'gradle.properties', 'gradle/**', 'gradlew*'] concurrency: @@ -27,6 +27,8 @@ jobs: fetch-depth: 0 # Spotless 的 ratchetFrom 需要完整提交历史。 - name: Setup Build uses: ./.github/actions/build_setup + with: + ref: ${{ github.sha }} - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Get Mod Version @@ -55,22 +57,23 @@ jobs: retention-days: 90 - name: Changelog id: changelog - if: ${{ env.PUBLISH == 'true' }} + if: ${{ env.PUBLISH == 'true' && !github.event.created }} uses: mikepenz/release-changelog-builder-action@v5 with: configuration: "./.github/json/config-latest.json" - toTag: ${{ github.ref }} + fromTag: ${{ github.event.before }} + toTag: ${{ github.sha }} fetchViaCommits: true failOnError: false - name: Release Latest if: ${{ env.PUBLISH == 'true' }} uses: andelf/nightly-release@46e2d5f80828ecc5c2c3c819eb31186a7cf2156c with: - tag_name: latest + tag_name: latest-${{ github.ref_name }} name: 'MixinSplice ${{ steps.ver.outputs.version }} SNAPSHOT ${{ env.VERSION_SUFFIX }}' prerelease: true body: | - The latest build of MixinSplice for Fabric, Forge, and NeoForge. + The latest build of MixinSplice from `${{ github.ref_name }}` for Fabric, Forge, and NeoForge. Please report any [issues](${{ github.server_url }}/${{ github.repository }}/issues). ${{ steps.changelog.outputs.changelog }} files: build/libs/*.jar diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 26a73e7..5148d9d 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -36,7 +36,7 @@ jobs: secrets: inherit uses: ./.github/workflows/publish.yml with: - simulate: ${{ startsWith(github.event.release.name, 'simulate') || github.repository_owner != 'ExtremelyFrozen' }} + simulate: ${{ startsWith(github.event.release.name, 'simulate') || github.repository != 'ModularMCLib/MixinSplice' }} tag-name: ${{ github.ref_name }} release-body: ${{ github.event.release.body }} changelog-body: ${{ needs.meta.outputs.CHANGELOG }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7e120c2..f46c23f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,11 +32,11 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: refs/tags/${{ inputs.tag-name }} - name: Setup Build uses: ./.github/actions/build_setup with: - ref: ${{ inputs.branch }} + ref: refs/tags/${{ inputs.tag-name }} - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Get Version @@ -78,6 +78,98 @@ jobs: files: ./*.jar fail_on_unmatched_files: true + publish-cf: + name: Publish to CurseForge (${{ matrix.loader }}) + needs: build + if: ${{ !inputs.simulate }} + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + fail-fast: false + matrix: + include: + - loader: fabric + java: | + 21 + 25 + game-versions: | + 1.21 + 1.21.1 + 1.21.2 + 1.21.3 + 1.21.4 + 1.21.5 + 1.21.6 + 1.21.7 + 1.21.8 + 1.21.9 + 1.21.10 + 1.21.11 + 26.1 + 26.1.1 + 26.1.2 + 26.2 + 26.3 + - loader: forge + java: '21' + # Forge 没有为 1.21.2 发布版本。当前平台包的 Forge 上限为 62 独占。 + game-versions: | + 1.21 + 1.21.1 + 1.21.3 + 1.21.4 + 1.21.5 + 1.21.6 + 1.21.7 + 1.21.8 + 1.21.9 + 1.21.10 + 1.21.11 + - loader: neoforge + java: | + 21 + 25 + game-versions: | + 1.21.1 + 1.21.2 + 1.21.3 + 1.21.4 + 1.21.5 + 1.21.6 + 1.21.7 + 1.21.8 + 1.21.9 + 1.21.10 + 1.21.11 + 26.1 + 26.1.1 + 26.1.2 + 26.2 + 26.3 + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.tag-name }} + - name: Publish Mod + uses: Kira-NT/mc-publish@v3.3.1 + with: + curseforge-id: ${{ vars.CURSEFORGE_ID }} + curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} + # 各平台包已内嵌共享库。 + curseforge-dependencies: '' + files: ./mixinsplice-${{ matrix.loader }}-${{ needs.build.outputs.ver }}.jar + name: 'MixinSplice ${{ needs.build.outputs.ver }} (${{ matrix.loader }})' + version: ${{ needs.build.outputs.ver }} + version-type: beta + changelog: ${{ inputs.release-body }} + environment: client | server + loaders: ${{ matrix.loader }} + game-versions: ${{ matrix.game-versions }} + java: ${{ matrix.java }} + fail-mode: fail + # 发布成功后,通过 PR 更新版本号和变更日志。 bump-version-and-changelog: name: Bump Version and Build Changelog @@ -87,26 +179,32 @@ jobs: permissions: contents: write pull-requests: write + env: + RELEASE_BRANCH: ${{ github.event.release.target_commitish }} steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: refs/heads/${{ env.RELEASE_BRANCH }} - name: Bump Version + env: + RELEASE_VERSION: ${{ needs.build.outputs.ver }} run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' - git switch -C gh/release-${{ inputs.branch }} - BUMPED=$(echo ${{ needs.build.outputs.ver }} | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.) - sed -i "s/= ${{ needs.build.outputs.ver }}/= ${BUMPED}/" gradle.properties + git switch -C "gh/release-${RELEASE_BRANCH}" + BUMPED=$(echo "$RELEASE_VERSION" | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.) + sed -i "s/^mod_version = ${RELEASE_VERSION}$/mod_version = ${BUMPED}/" gradle.properties git commit -am "Bump version to ${BUMPED}" - name: Prepend to CHANGELOG if: inputs.changelog-body + env: + CHANGELOG_BODY: ${{ inputs.changelog-body }} run: | - { head -n 2 CHANGELOG.md; echo -e "${{ inputs.changelog-body }}"; tail -n +3 CHANGELOG.md; } > temp.md && mv temp.md CHANGELOG.md + { head -n 2 CHANGELOG.md; printf '%s\n' "$CHANGELOG_BODY"; tail -n +3 CHANGELOG.md; } > temp.md && mv temp.md CHANGELOG.md git commit -am "Updated CHANGELOG" - name: Push and PR env: GH_TOKEN: ${{ github.token }} run: | - git push --force --set-upstream origin gh/release-${{ inputs.branch }} - gh pr create -B ${{ inputs.branch }} -H gh/release-${{ inputs.branch }} --title "RELEASE for ${{ inputs.branch }} [no-snapshot]" --body "Created by GH Workflow" --label "ignore changelog" + git push --force --set-upstream origin "gh/release-${RELEASE_BRANCH}" + gh pr create -B "$RELEASE_BRANCH" -H "gh/release-${RELEASE_BRANCH}" --title "RELEASE for ${RELEASE_BRANCH} [no-snapshot]" --body "Created by GH Workflow" --label "ignore changelog" diff --git a/docs/architecture.md b/docs/architecture.md index 000d095..e518f4f 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -19,7 +19,7 @@ MixinSplice 是 SpongePowered Mixin 的扩展。动态目标、跨 Mixin 注入 `:core` 将 API、实现和 javac 插件打进 `mixinsplice-common`。三平台都引用 `:core` 的 `commonElements`。Fabric 通过 Loom 的 `include` 把共享库嵌入 `META-INF/jars/`,Loom 生成 `fabric.mod.json` 的 `jars` 声明。共享库的 Fabric ID 为 `mixinsplice_common`。Forge 通过 Forge JarJar 插件打包,NeoForge 通过 NeoGradle 打包,两者用 `jarJar` 依赖把共享库放进 `META-INF/jarjar/` 并生成元数据。共享库的 Manifest 声明 `FMLModType: GAMELIBRARY`,供 Forge 和 NeoForge 将它载入游戏层。 -初始化配置 `mixinsplice.mixins.json` 随平台包分发。Fabric 在 `fabric.mod.json` 中声明 `mixins`,Forge 在 Manifest 中声明 `MixinConfigs`,NeoForge 在 `neoforge.mods.toml` 中声明 `[[mixins]]`。Forge 和 NeoForge 使用 `lowcodefml` 注册平台模组。共享库提供配置中的插件类 `MixinSpliceConfigPlugin`。配置的 `package` 为 `core.mixins`,让 Mixin 将该包前缀留给 Mixin 类,插件及运行时类位于 `core.mixin`。 +初始化配置 `mixinsplice.mixins.json` 随平台包分发。Fabric 在 `fabric.mod.json` 中声明 `mixins`,Forge 在 Manifest 中声明 `MixinConfigs`,NeoForge 在 `neoforge.mods.toml` 中声明 `[[mixins]]`。Forge 使用 `lowcodefml` 注册平台模组,NeoForge 使用 `javafml` 并保留 FML 版本下限。共享库提供配置中的插件类 `MixinSpliceConfigPlugin`。配置的 `package` 为 `core.mixins`,让 Mixin 将该包前缀留给 Mixin 类,插件及运行时类位于 `core.mixin`。 消费方通过自己的平台元数据注册自己的 `mixins.json`。平台包作为独立 Mod 安装或作为消费方的 Jar-in-Jar 依赖加载时,都会自动注册 MixinSplice 的初始化配置。 @@ -75,6 +75,14 @@ Fabric 的 `:loader:fabric:runGameTestServer` 使用 Loom 的生产服务端任 PR 的 CI 依次启动 Fabric 服务端、Forge 服务端和 NeoForge GameTest 服务端,最后执行 `:tests:test`。四项结果共同决定 PR 的测试标签和作业状态。 +## 发布与维护分支 + +`main` 跟随 MixinSplice 的最新主版本。不兼容升级时,从升级前的提交切出 `N.x` 维护分支,按需回移修复。`N` 取 MixinSplice 的主版本号。创建正式 Release 时,从对应的 `main` 或 `N.x` 创建完整版本号标签。版本更新 PR 指向 Release 记录的目标分支。 + +推送源码或 Gradle 配置到 `main` 和 `N.x` 时,CI 构建该次推送的提交。GitHub 快照标签使用 `latest-分支名`,例如 `latest-main` 和 `latest-1.x`。快照变更日志使用本次推送的提交范围。 + +CurseForge 发布需要 GitHub Actions 变量 `CURSEFORGE_ID` 和密钥 `CURSEFORGE_TOKEN`。各加载器的 Minecraft 版本清单随相应发行线的发布配置维护。 + ## 上游参考 MixinSplice 按现有模块和公开契约重新实现以下能力。 diff --git a/loader/neoforge/src/main/templates/META-INF/neoforge.mods.toml b/loader/neoforge/src/main/templates/META-INF/neoforge.mods.toml index 4251a12..965e2ec 100644 --- a/loader/neoforge/src/main/templates/META-INF/neoforge.mods.toml +++ b/loader/neoforge/src/main/templates/META-INF/neoforge.mods.toml @@ -1,4 +1,4 @@ -modLoader = "lowcodefml" +modLoader = "javafml" loaderVersion = "${loader_version_range}" issueTrackerURL = "${mod_issue_tracker}" license = "${mod_license}"