From 623a43b26d16d6da268ae290bd76ebe05f577e91 Mon Sep 17 00:00:00 2001 From: Ap_Tx <3045929398@qq.com> Date: Sat, 3 Oct 2026 17:22:40 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E5=8F=91=E5=B8=83=E6=97=B6=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8A=E4=BC=A0=E5=88=B0=20Modrinth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release.yml 在 GitHub Release 之后用 Kir-Antipov/mc-publish@v3.3 上传 jar 到 Modrinth,project 用 slug better-place-command;发布配置读仓库根 modrinth.json(project_id/loaders/game_versions/version_type)。含 test 的 tag 会跳过 Modrinth 发布。 新增 modrinth.json 作为发布元数据单一真源。 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++-- modrinth.json | 10 ++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 modrinth.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95cf365..7690674 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: - name: Build with Gradle run: ./gradlew build -Pmod_version=${{ steps.ver.outputs.version }} --stacktrace - - name: Create Release + - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ steps.ver.outputs.tag }} @@ -53,4 +53,28 @@ jobs: generate_release_notes: true files: build/libs/*.jar draft: false - prerelease: false \ No newline at end of file + prerelease: false + + - name: Read Modrinth metadata + id: meta + run: | + echo "project_id=$(jq -r .project_id modrinth.json)" >> "$GITHUB_OUTPUT" + echo "loaders=$(jq -r '.loaders | join(\",\")' modrinth.json)" >> "$GITHUB_OUTPUT" + echo "game_versions=$(jq -r '.game_versions | join(\",\")' modrinth.json)" >> "$GITHUB_OUTPUT" + echo "version_type=$(jq -r .version_type modrinth.json)" >> "$GITHUB_OUTPUT" + + - name: Publish to Modrinth + # 仅在正式 tag 时发布(跳过含 test 的 tag) + if: ${{ !contains(steps.ver.outputs.tag, 'test') }} + uses: Kir-Antipov/mc-publish@v3.3 + with: + modrinth-id: ${{ steps.meta.outputs.project_id }} + modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + files: build/libs/minecraft-place-mod-${{ steps.ver.outputs.version }}.jar + name: ${{ steps.ver.outputs.tag }} + version: ${{ steps.ver.outputs.version }} + version-type: ${{ steps.meta.outputs.version_type }} + loaders: ${{ steps.meta.outputs.loaders }} + game-versions: ${{ steps.meta.outputs.game_versions }} + changelog: 详见 GitHub Release。 + modrinth-featured: false \ No newline at end of file diff --git a/modrinth.json b/modrinth.json new file mode 100644 index 0000000..7fbb1d1 --- /dev/null +++ b/modrinth.json @@ -0,0 +1,10 @@ +{ + "project_id": "better-place-command", + "version_type": "release", + "loaders": [ + "fabric" + ], + "game_versions": [ + "26.1.2" + ] +} \ No newline at end of file