From a435c3b272a2dd300f329b2345c13945fed09122 Mon Sep 17 00:00:00 2001 From: 3944Realms Date: Wed, 18 Mar 2026 21:15:24 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=B7=A5=E4=BD=9C=E6=B5=81=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/buildAndRelease.yml | 43 ++++++++++++++++++++------- gradle.properties | 7 ++++- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/buildAndRelease.yml b/.github/workflows/buildAndRelease.yml index bdc1eac..5c0ad8b 100644 --- a/.github/workflows/buildAndRelease.yml +++ b/.github/workflows/buildAndRelease.yml @@ -118,13 +118,33 @@ jobs: echo "modrinth_id=MODRINTH_ID" >> $GITHUB_OUTPUT # 从 gradle.properties 提取 curseforge_id CURSEFORGE_ID=$(grep "^curseforge_id=" gradle.properties | cut -d'=' -f2 || echo "Curseforge ID") - echo "curseforge_id=$CURSEFORGE_ID" >> $GITHUB_OUTPUT # 读取 Java 版本列表 - 方法: 使用 JSON 数组格式 - JAVA_VERSIONS_JSON=$(grep "^java_versions=" gradle.properties | cut -d'=' -f2- || echo 'Java Versions') + echo "curseforge_id=$CURSEFORGE_ID" >> $GITHUB_OUTPUT + # 读取 Java 版本列表 - JAVA_VERSIONS_JSON=$(grep "^java_versions=" gradle.properties | cut -d'=' -f2- || echo '["21","17"]') - JAVA_VERSIONS_JSON=$(echo "$JAVA_VERSIONS_JSON" | sed 's/^"//;s/"$//') - echo "java_versions_json=$JAVA_VERSIONS_JSON" >> $GITHUB_OUTPUT + JAVA_VERSIONS=$(grep "^java_versions=" gradle.properties | cut -d'=' -f2- || echo 'Java Versions') + JAVA_VERSIONS=$(echo "$JAVA_VERSIONS" | sed 's/^"//;s/"$//') + echo "java_versions=$JAVA_VERSIONS" >> $GITHUB_OUTPUT + # 读取发布控制布尔值(默认都为 true) + PUBLISH_GITHUB=$(grep "^publish_github=" gradle.properties | cut -d'=' -f2 | tr '[:upper:]' '[:lower:]' || echo "true") + if [ "$PUBLISH_GITHUB" = "true" ] || [ "$PUBLISH_GITHUB" = "1" ] || [ "$PUBLISH_GITHUB" = "yes" ]; then + echo "publish_github=true" >> $GITHUB_OUTPUT + else + echo "publish_github=false" >> $GITHUB_OUTPUT + fi + PUBLISH_MODRINTH=$(grep "^publish_modrinth=" gradle.properties | cut -d'=' -f2 | tr '[:upper:]' '[:lower:]' || echo "true") + if [ "$PUBLISH_MODRINTH" = "true" ] || [ "$PUBLISH_MODRINTH" = "1" ] || [ "$PUBLISH_MODRINTH" = "yes" ]; then + echo "publish_modrinth=true" >> $GITHUB_OUTPUT + else + echo "publish_modrinth=false" >> $GITHUB_OUTPUT + fi + + PUBLISH_CURSEFORGE=$(grep "^publish_curseforge=" gradle.properties | cut -d'=' -f2 | tr '[:upper:]' '[:lower:]' || echo "true") + if [ "$PUBLISH_CURSEFORGE" = "true" ] || [ "$PUBLISH_CURSEFORGE" = "1" ] || [ "$PUBLISH_CURSEFORGE" = "yes" ]; then + echo "publish_curseforge=true" >> $GITHUB_OUTPUT + else + echo "publish_curseforge=false" >> $GITHUB_OUTPUT + fi # 读取 Fabric 的 Modrinth 依赖配置 FABRIC_MODRINTH_DEPS_RAW=$(grep "^fabric_modrinth_dependencies=" gradle.properties | cut -d'=' -f2- || echo "[]") FABRIC_MODRINTH_DEPS_JSON=$(echo "$FABRIC_MODRINTH_DEPS_RAW" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | tr -d '\r') @@ -298,6 +318,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT - name: Create Release + if: steps.version_info.outputs.publish_github == 'true' uses: ncipollo/release-action@v1 with: artifacts: | @@ -313,7 +334,7 @@ jobs: # Fabric 发布到 Modrinth 和 CurseForge - name: Publish Fabric to Modrinth & CurseForge uses: Kir-Antipov/mc-publish@v3.3 - if: success() + if: success() && (steps.version_info.outputs.publish_modrinth == 'true' || steps.version_info.outputs.publish_curseforge == 'true') continue-on-error: true with: # 文件匹配规则 - 只匹配 fabric 的文件 @@ -347,11 +368,11 @@ jobs: modrinth-token: ${{ secrets.MODRINTH_TOKEN }} modrinth-featured: true modrinth-unfeature-mode: any - modrinth-dependencies: ${{ steps.version_info.outputs.modrinth_dependencies }} + modrinth-dependencies: ${{ steps.version_info.outputs.fabric_modrinth_dependencies }} # CurseForge 配置 curseforge-id: ${{ steps.version_info.outputs.curseforge_id }} curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - curseforge-dependencies: ${{ steps.version_info.outputs.curseforge_dependencies }} + curseforge-dependencies: ${{ steps.version_info.outputs.fabric_curseforge_dependencies }} # 明确指定主文件和附加文件 files-primary: dist/${{ steps.version_info.outputs.mod_id }}-fabric-${{ steps.version_info.outputs.minecraft_version }}-${{ steps.version_info.outputs.version }}.jar @@ -365,7 +386,7 @@ jobs: # Forge 发布到 Modrinth 和 CurseForge - name: Publish Forge to Modrinth & CurseForge uses: Kir-Antipov/mc-publish@v3.3 - if: success() + if: success() && (steps.version_info.outputs.publish_modrinth == 'true' || steps.version_info.outputs.publish_curseforge == 'true') continue-on-error: true with: # 文件匹配规则 - 只匹配 forge 的文件 @@ -399,12 +420,12 @@ jobs: modrinth-token: ${{ secrets.MODRINTH_TOKEN }} modrinth-featured: true modrinth-unfeature-mode: any - modrinth-dependencies: ${{ steps.version_info.outputs.modrinth_dependencies }} + modrinth-dependencies: ${{ steps.version_info.outputs.forge_modrinth_dependencies }} # CurseForge 配置 curseforge-id: ${{ steps.version_info.outputs.curseforge_id }} curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} - curseforge-dependencies: ${{ steps.version_info.outputs.curseforge_dependencies }} + curseforge-dependencies: ${{ steps.version_info.outputs.forge_curseforge_dependencies }} # 明确指定主文件和附加文件 files-primary: dist/${{ steps.version_info.outputs.mod_id }}-forge-${{ steps.version_info.outputs.minecraft_version }}-${{ steps.version_info.outputs.version }}.jar diff --git a/gradle.properties b/gradle.properties index fd53cef..0f94472 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ # Every field you add must be added to buildSrc/src/main/groovy/multiloader-common.gradle expandProps map. # Project -version=0.5.1-beta +version=0.5.2-beta group=top.r3944realms.lib39 java_version=17 @@ -32,6 +32,11 @@ forge_loader_version_range=[47,) org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false +# Release +publish_github=true +publish_modrinth=true +publish_curseforge=true + modrinth_id=n65Vs1Vk curseforge_id=1445917