From a672e27bfe158c58de4a378de5558666246ae305 Mon Sep 17 00:00:00 2001 From: QiuYe Date: Fri, 20 Nov 2026 17:44:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=85=8D=E7=BD=AE=201.21.1=20=E5=92=8C=202?= =?UTF-8?q?6.1=20=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/build_setup/action.yml | 4 +- .github/json/config-1.21.json | 45 ++++++++++++ .github/json/config-latest-1.21.json | 35 ++++++++++ .github/workflows/auto-build.yml | 22 +++--- .github/workflows/publish-on-release.yml | 42 +++++++++--- .github/workflows/publish.yml | 83 ++++++++++++++++------- .github/workflows/update-gradle-cache.yml | 2 +- 7 files changed, 184 insertions(+), 49 deletions(-) create mode 100644 .github/json/config-1.21.json create mode 100644 .github/json/config-latest-1.21.json diff --git a/.github/actions/build_setup/action.yml b/.github/actions/build_setup/action.yml index c1bf4ed..bb0286a 100644 --- a/.github/actions/build_setup/action.yml +++ b/.github/actions/build_setup/action.yml @@ -22,11 +22,11 @@ runs: REF: ${{ inputs.ref || github.ref }} with: distribution: temurin - java-version: 25 + java-version: ${{ (github.ref_name == '1.21' || github.base_ref == '1.21' || endsWith(github.ref_name, '-1.21')) && '21' || '25' }} - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 with: cache-write-only: ${{ inputs.update-cache }} - cache-read-only: ${{ github.ref != 'refs/heads/26.1' }} + cache-read-only: ${{ github.ref != 'refs/heads/26.1' && github.ref != 'refs/heads/1.21' }} add-job-summary: 'on-failure' diff --git a/.github/json/config-1.21.json b/.github/json/config-1.21.json new file mode 100644 index 0000000..a726d5d --- /dev/null +++ b/.github/json/config-1.21.json @@ -0,0 +1,45 @@ +{ + "categories": [ + { + "title": "### Added", + "labels": ["type: feature"] + }, + { + "title": "### Fixed", + "labels": ["type: bugfix"] + }, + { + "title": "### Changed", + "labels": ["type: refactor", "type: translation"] + } + ], + "sort": "ASC", + "template": "## Version [v#{{VERSION}}](#{{RELEASE_DIFF}})\n#{{CHANGELOG}} ", + "pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})", + "custom_placeholders": [ + { + "name": "VERSION", + "source": "TO_TAG", + "transformer": { + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" + } + } + ], + "empty_template": "", + "ignore_labels": ["ignore changelog"], + "tag_resolver": { + "method": "semver", + "filter": { + "pattern": "^(?!v?[0-9\\.]+(-1\\.21)$).+$", + "flags": "gu" + }, + "transformer": { + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" + } + }, + "max_pull_requests": 1000, + "max_back_track_time_days": 365, + "base_branches": ["1.21"] +} diff --git a/.github/json/config-latest-1.21.json b/.github/json/config-latest-1.21.json new file mode 100644 index 0000000..3ebbf9f --- /dev/null +++ b/.github/json/config-latest-1.21.json @@ -0,0 +1,35 @@ +{ + "categories": [ + { + "title": "### Added", + "labels": ["type: feature"] + }, + { + "title": "### Fixed", + "labels": ["type: bugfix"] + }, + { + "title": "### Changed", + "labels": ["type: refactor", "type: translation"] + } + ], + "sort": "ASC", + "template": "## What's Changed since #{{FROM_TAG}}\n#{{CHANGELOG}}\n#{{UNCATEGORIZED}}\n#{{CHANGES}} lines changed - see the [full diff here](#{{RELEASE_DIFF}})", + "pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})", + "empty_template": "", + "ignore_labels": ["ignore changelog"], + "tag_resolver": { + "method": "semver", + "filter": { + "pattern": "^(?!v?[0-9\\.]+(-1\\.21)$).+$", + "flags": "gu" + }, + "transformer": { + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" + } + }, + "max_pull_requests": 1000, + "max_back_track_time_days": 365, + "base_branches": ["1.21"] +} diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml index 11a480b..0031e10 100644 --- a/.github/workflows/auto-build.yml +++ b/.github/workflows/auto-build.yml @@ -2,7 +2,7 @@ name: Latest Build on: push: - branches: ['26.1'] + branches: ['26.1', '1.21'] paths: ['src/**', '**/*.gradle', 'gradle.properties'] concurrency: @@ -14,13 +14,12 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ github.token }} - PUBLISH: ${{ !contains(github.event.commits[0].message, '[no-snapshot]') }} - MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - MAVEN_USER: ${{ secrets.MAVEN_USER }} + PUBLISH: ${{ !contains(github.event.head_commit.message, '[no-snapshot]') }} SNAPSHOT: true CI: true permissions: contents: write + pull-requests: read steps: - uses: actions/checkout@v4 with: @@ -31,15 +30,20 @@ jobs: run: chmod +x gradlew - name: Get Mod Version id: ver - run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT + run: | + version=$(./gradlew -q printVersion) + printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT" - name: Version Suffix - id: suffix - run: echo "VERSION_SUFFIX=$(echo "${{ github.sha }}" | cut -c 1-7)" >> $GITHUB_ENV + run: printf 'VERSION_SUFFIX=%s\n' "${GITHUB_SHA:0:7}" >> "$GITHUB_ENV" - name: Build run: ./gradlew build - name: Rename Jars if: ${{ env.PUBLISH == 'true' }} - run: for file in build/libs/*; do mv "$file" "${file/SHOT/SHOT+$(date --utc '+%Y%m%d-%H%M%S')-${{ env.VERSION_SUFFIX }}}"; done; + run: | + timestamp=$(date --utc '+%Y%m%d-%H%M%S') + for file in build/libs/*-SNAPSHOT*.jar; do + mv "$file" "${file/-SNAPSHOT/-SNAPSHOT+$timestamp-$VERSION_SUFFIX}" + done - name: Upload Artifacts if: ${{ env.PUBLISH == 'true' }} uses: actions/upload-artifact@v4 @@ -53,7 +57,7 @@ jobs: if: ${{ env.PUBLISH == 'true' }} uses: mikepenz/release-changelog-builder-action@v5 with: - configuration: "./.github/json/config-latest.json" + configuration: "./.github/json/config-latest${{ github.ref_name == '1.21' && '-1.21' || '' }}.json" toTag: ${{ github.ref }} fetchViaCommits: true failOnError: false diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index ecd72fb..525d850 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -7,33 +7,37 @@ on: jobs: meta: name: Metadata + if: endsWith(github.ref_name, '-26.1') || endsWith(github.ref_name, '-1.21') runs-on: ubuntu-latest - outputs: - CHANGELOG: ${{ steps.changelog.outputs.changelog }} permissions: - contents: write + contents: read pull-requests: read + outputs: + changelog: ${{ steps.changelog.outputs.changelog }} steps: - name: Get Config uses: actions/checkout@v4 with: - ref: ${{ github.ref_name }} - sparse-checkout: '.github/json' + ref: ${{ github.ref }} + fetch-depth: 0 + sparse-checkout: .github/json - name: Generate changelog id: changelog - env: - GITHUB_TOKEN: ${{ github.token }} uses: mikepenz/release-changelog-builder-action@v5 with: - configuration: './.github/json/config.json' + token: ${{ github.token }} + configuration: "./.github/json/config${{ endsWith(github.ref_name, '-1.21') && '-1.21' || '' }}.json" ignorePreReleases: true fetchViaCommits: true failOnError: true publish-26: name: '26.1' - needs: [ meta ] - if: ${{ contains(github.ref_name, '26.1') }} + needs: meta + if: endsWith(github.ref_name, '-26.1') + permissions: + contents: write + pull-requests: write secrets: inherit uses: ./.github/workflows/publish.yml with: @@ -41,4 +45,20 @@ jobs: tag-name: ${{ github.ref_name }} version: '26.1' release-body: ${{ github.event.release.body }} - changelog-body: ${{ needs.meta.outputs.CHANGELOG }} \ No newline at end of file + changelog-body: ${{ needs.meta.outputs.changelog }} + + publish-21: + name: '1.21.1' + needs: meta + if: endsWith(github.ref_name, '-1.21') + permissions: + contents: write + pull-requests: write + secrets: inherit + uses: ./.github/workflows/publish.yml + with: + simulate: ${{ startsWith(github.event.release.name, 'simulate') || github.repository_owner != 'ModularMCLib' }} + tag-name: ${{ github.ref_name }} + version: '1.21' + 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 c822ec7..96adbc8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ on: required: true type: string version: - description: 'Version identifier;' + description: 'Version branch to update after publishing' required: true type: string release-body: @@ -28,7 +28,7 @@ jobs: name: Build and Publish to Maven runs-on: ubuntu-latest permissions: - contents: write + contents: read env: CI: 'true' outputs: @@ -36,16 +36,19 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: refs/tags/${{ inputs.tag-name }} + persist-credentials: false - 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 id: ver - run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT + run: | + version=$(./gradlew -q printVersion) + printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT" - name: Build run: ./gradlew assemble - name: Upload Build Artifacts @@ -91,13 +94,13 @@ jobs: # - name: Download artifacts # uses: actions/download-artifact@v4 # with: -# name: build-artifacts-${{ inputs.branch }} +# name: build-artifacts-${{ inputs.tag-name }} # - name: Publish Mod # env: -# MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }} -# LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }} -# JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }} -# VERSION_TYPE: ${{ inputs.branch == '1.21' && 'beta' || 'beta' }} +# MC_VERSION: ${{ inputs.version == '1.21' && '1.21.1' || '26.1.2' }} +# LOADER: neoforge +# JAVA: ${{ inputs.version == '1.21' && '21' || '25' }} +# VERSION_TYPE: beta # uses: Kir-Antipov/mc-publish@v3.3.0 # with: # modrinth-id: aADDBrNC @@ -124,13 +127,13 @@ jobs: # - name: Download artifacts # uses: actions/download-artifact@v4 # with: -# name: build-artifacts-${{ inputs.branch }} +# name: build-artifacts-${{ inputs.tag-name }} # - name: Publish Mod # env: -# MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }} -# LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }} -# JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }} -# VERSION_TYPE: ${{ inputs.branch == '1.21' && 'alpha' || 'beta' }} +# MC_VERSION: ${{ inputs.version == '1.21' && '1.21.1' || '26.1.2' }} +# LOADER: neoforge +# JAVA: ${{ inputs.version == '1.21' && '21' || '25' }} +# VERSION_TYPE: ${{ inputs.version == '1.21' && 'alpha' || 'beta' }} # uses: Kir-Antipov/mc-publish@v3.3.0 # with: # curseforge-id: 1397216 @@ -150,7 +153,8 @@ jobs: bump-version-and-changelog: name: Bump Version and Build Changelog needs: [ build, upload-release-artifacts ] - if: ${{ always() && !failure() && !cancelled() }} + concurrency: + group: release-update-${{ inputs.version }} runs-on: ubuntu-latest permissions: contents: write @@ -158,23 +162,50 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: refs/heads/${{ inputs.version }} + fetch-depth: 0 - name: Bump Version + env: + RELEASE_BRANCH: ${{ inputs.version }} + 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.version }} - BUMPED=$(echo ${{ needs.build.outputs.ver }} | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.) - sed -i "s/= ${{ needs.build.outputs.ver }}/= ${BUMPED}/" gradle.properties - git commit -am "Bump version to ${BUMPED}" + git switch -c "gh/release-$RELEASE_BRANCH" + current=$(sed -nE 's/^mod_version[[:blank:]]*=[[:blank:]]*(.*)$/\1/p' gradle.properties) + if [[ $current == "$RELEASE_VERSION" ]]; then + bumped=$(awk 'BEGIN { FS = OFS = "." } { $NF++; print }' <<< "$RELEASE_VERSION") + sed -i -E "s/^(mod_version[[:blank:]]*=[[:blank:]]*).*/\1$bumped/" gradle.properties + git commit -m "Bump version to $bumped" -- gradle.properties + fi - name: Prepend to CHANGELOG - if: inputs.changelog-body + if: inputs.changelog-body != '' + env: + CHANGELOG_BODY: ${{ inputs.changelog-body }} + RELEASE_VERSION: ${{ needs.build.outputs.ver }} run: | - { head -n 2 CHANGELOG.md; echo -e "${{ inputs.changelog-body }}"; tail -n +3 CHANGELOG.md; } > temp.md && mv temp.md CHANGELOG.md - git commit -am "Updated CHANGELOG" + if git grep -Fq "## Version [v$RELEASE_VERSION](" -- CHANGELOG.md; then + exit 0 + fi + { + head -n 2 CHANGELOG.md + printf '%s\n' "$CHANGELOG_BODY" + tail -n +3 CHANGELOG.md + } > changelog.tmp + mv changelog.tmp CHANGELOG.md + git commit -m 'Updated CHANGELOG' -- CHANGELOG.md - name: Push and PR env: GH_TOKEN: ${{ github.token }} + RELEASE_BRANCH: ${{ inputs.version }} run: | - git push --force --set-upstream origin gh/release-${{ inputs.version }} - gh pr create -B ${{ inputs.version }} -H gh/release-${{ inputs.version }} --title "RELEASE for ${{ inputs.version }} [no-snapshot]" --body "Created by GH Workflow" --label "ignore changelog" + if git diff --quiet "refs/remotes/origin/$RELEASE_BRANCH" HEAD; then + exit 0 + fi + pr_branch="gh/release-$RELEASE_BRANCH" + git push --force-with-lease origin "HEAD:refs/heads/$pr_branch" + pull_request=$(gh pr list --base "$RELEASE_BRANCH" --head "$pr_branch" --json number --jq '.[0].number // empty') + if [[ -z $pull_request ]]; then + gh pr create --base "$RELEASE_BRANCH" --head "$pr_branch" --title "RELEASE for $RELEASE_BRANCH [no-snapshot]" \ + --body 'Created by GH Workflow' --label 'ignore changelog' + fi diff --git a/.github/workflows/update-gradle-cache.yml b/.github/workflows/update-gradle-cache.yml index 1146b6b..51fd9f7 100644 --- a/.github/workflows/update-gradle-cache.yml +++ b/.github/workflows/update-gradle-cache.yml @@ -3,7 +3,7 @@ name: Update Gradle Cache on: push: - branches: ['26.1'] + branches: ['26.1', '1.21'] paths: ['gradle/**', '**/*.gradle', 'gradle.properties', 'gradlew*', 'src/main/resources/META-INF/accesstransformer.cfg'] workflow_dispatch: From bff8180ad1a01cc08abaaaf173a506742eaf8978 Mon Sep 17 00:00:00 2001 From: QiuYe Date: Fri, 20 Nov 2026 17:45:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=88=86=E6=94=AF=E7=9A=84=20CI=20=E5=88=B0=201.21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/sync.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 4890463..8fc1b38 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -6,18 +6,33 @@ on: paths: ['.github/**'] jobs: - sync: + sync-21: + name: Sync to 1.21 + concurrency: workflow-sync-1.21 runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 - - run: | + with: + ref: '1.21' + fetch-depth: 0 + - name: Copy .github from 26.1 and open pull request + run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' - git switch -C gh/workflow-sync - git fetch origin - git checkout origin/26.1 -- .github - git add .github - git commit --allow-empty -m "Sync Workflows" - git push --force --set-upstream origin gh/workflow-sync + git switch -c gh/workflow-sync-1.21 + git restore --source=origin/26.1 --staged --worktree -- .github + if git diff --cached --quiet; then + exit 0 + fi + git commit -m 'Sync Workflows' + git push --force-with-lease origin HEAD:refs/heads/gh/workflow-sync-1.21 + pull_request=$(gh pr list --base 1.21 --head gh/workflow-sync-1.21 --json number --jq '.[0].number // empty') + if [[ -z $pull_request ]]; then + gh pr create --base 1.21 --head gh/workflow-sync-1.21 --title 'Sync Workflows with 26.1 [no-snapshot]' \ + --body 'Created by GH Workflow' --label 'ignore changelog' + fi From 5f0cbad053c2957432e50fd54dd571973cf909a3 Mon Sep 17 00:00:00 2001 From: QiuYe Date: Fri, 20 Nov 2026 18:05:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8C=89=20GregTech-Modern=20=E6=81=A2?= =?UTF-8?q?=E5=A4=8D=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/build_setup/action.yml | 4 +- .github/workflows/auto-build.yml | 25 +++---- .github/workflows/publish-on-release.yml | 40 +++++------ .github/workflows/publish.yml | 83 +++++++---------------- .github/workflows/sync.yml | 29 +++----- .github/workflows/update-gradle-cache.yml | 2 - 6 files changed, 64 insertions(+), 119 deletions(-) diff --git a/.github/actions/build_setup/action.yml b/.github/actions/build_setup/action.yml index bb0286a..c852a0c 100644 --- a/.github/actions/build_setup/action.yml +++ b/.github/actions/build_setup/action.yml @@ -19,10 +19,10 @@ runs: - name: Set up JDK uses: actions/setup-java@v4 env: - REF: ${{ inputs.ref || github.ref }} + REF: ${{ inputs.ref || github.base_ref || github.ref }} with: distribution: temurin - java-version: ${{ (github.ref_name == '1.21' || github.base_ref == '1.21' || endsWith(github.ref_name, '-1.21')) && '21' || '25' }} + java-version: ${{ contains(env.REF, '1.21') && '21' || '25' }} - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml index 0031e10..dcf9748 100644 --- a/.github/workflows/auto-build.yml +++ b/.github/workflows/auto-build.yml @@ -14,36 +14,33 @@ jobs: runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ github.token }} - PUBLISH: ${{ !contains(github.event.head_commit.message, '[no-snapshot]') }} + PUBLISH: ${{ !contains(github.event.commits[0].message, '[no-snapshot]') }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + MAVEN_USER: ${{ secrets.MAVEN_USER }} SNAPSHOT: true CI: true permissions: contents: write - pull-requests: read steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # do a full checkout instead of a shallow clone of HEAD so spotless's ratchetFrom works - name: Setup Build uses: ./.github/actions/build_setup - - name: Grant execute permission for gradlew - run: chmod +x gradlew - name: Get Mod Version id: ver - run: | - version=$(./gradlew -q printVersion) - printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT" + run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT - name: Version Suffix - run: printf 'VERSION_SUFFIX=%s\n' "${GITHUB_SHA:0:7}" >> "$GITHUB_ENV" + id: suffix + run: echo "VERSION_SUFFIX=$(echo "${{ github.sha }}" | cut -c 1-7)" >> $GITHUB_ENV - name: Build run: ./gradlew build + - name: Publish to Maven + if: ${{ github.repository_owner == 'ModularMCLib' && env.PUBLISH == 'true' }} + run: ./gradlew publish - name: Rename Jars if: ${{ env.PUBLISH == 'true' }} - run: | - timestamp=$(date --utc '+%Y%m%d-%H%M%S') - for file in build/libs/*-SNAPSHOT*.jar; do - mv "$file" "${file/-SNAPSHOT/-SNAPSHOT+$timestamp-$VERSION_SUFFIX}" - done + run: for file in build/libs/*; do mv "$file" "${file/SHOT/SHOT+$(date --utc '+%Y%m%d-%H%M%S')-${{ env.VERSION_SUFFIX }}}"; done; - name: Upload Artifacts if: ${{ env.PUBLISH == 'true' }} uses: actions/upload-artifact@v4 @@ -57,7 +54,7 @@ jobs: if: ${{ env.PUBLISH == 'true' }} uses: mikepenz/release-changelog-builder-action@v5 with: - configuration: "./.github/json/config-latest${{ github.ref_name == '1.21' && '-1.21' || '' }}.json" + configuration: "./.github/json/config-latest${{ contains(github.ref_name, '1.21') && '-1.21' || '' }}.json" toTag: ${{ github.ref }} fetchViaCommits: true failOnError: false diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index 525d850..cf1ed07 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -7,37 +7,34 @@ on: jobs: meta: name: Metadata - if: endsWith(github.ref_name, '-26.1') || endsWith(github.ref_name, '-1.21') runs-on: ubuntu-latest + outputs: + CHANGELOG: ${{ steps.changelog.outputs.changelog }} permissions: - contents: read + contents: write pull-requests: read - outputs: - changelog: ${{ steps.changelog.outputs.changelog }} steps: - name: Get Config uses: actions/checkout@v4 with: - ref: ${{ github.ref }} - fetch-depth: 0 - sparse-checkout: .github/json + ref: ${{ github.ref_name }} + sparse-checkout: '.github/json' - name: Generate changelog id: changelog + env: + GITHUB_TOKEN: ${{ github.token }} + CONFIG: ${{ contains(github.ref_name, '1.21') && '-1.21' || '' }} uses: mikepenz/release-changelog-builder-action@v5 with: - token: ${{ github.token }} - configuration: "./.github/json/config${{ endsWith(github.ref_name, '-1.21') && '-1.21' || '' }}.json" + configuration: './.github/json/config${{ env.CONFIG }}.json' ignorePreReleases: true fetchViaCommits: true failOnError: true publish-26: - name: '26.1' - needs: meta - if: endsWith(github.ref_name, '-26.1') - permissions: - contents: write - pull-requests: write + name: 26.1 + needs: [ meta ] + if: ${{ contains(github.ref_name, '26.1') || !contains(github.ref_name, '1.21') }} secrets: inherit uses: ./.github/workflows/publish.yml with: @@ -45,15 +42,12 @@ jobs: tag-name: ${{ github.ref_name }} version: '26.1' release-body: ${{ github.event.release.body }} - changelog-body: ${{ needs.meta.outputs.changelog }} + changelog-body: ${{ needs.meta.outputs.CHANGELOG }} publish-21: - name: '1.21.1' - needs: meta - if: endsWith(github.ref_name, '-1.21') - permissions: - contents: write - pull-requests: write + name: 1.21.1 + needs: [ meta ] + if: ${{ contains(github.ref_name, '1.21') || !contains(github.ref_name, '26.1') }} secrets: inherit uses: ./.github/workflows/publish.yml with: @@ -61,4 +55,4 @@ jobs: tag-name: ${{ github.ref_name }} version: '1.21' release-body: ${{ github.event.release.body }} - changelog-body: ${{ needs.meta.outputs.changelog }} + changelog-body: ${{ needs.meta.outputs.CHANGELOG }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 96adbc8..5b05ad7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,7 +11,7 @@ on: required: true type: string version: - description: 'Version branch to update after publishing' + description: 'Version identifier; 26.1 or 1.21' required: true type: string release-body: @@ -28,7 +28,7 @@ jobs: name: Build and Publish to Maven runs-on: ubuntu-latest permissions: - contents: read + contents: write env: CI: 'true' outputs: @@ -36,19 +36,14 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: refs/tags/${{ inputs.tag-name }} - persist-credentials: false + ref: ${{ inputs.tag-name }} - name: Setup Build uses: ./.github/actions/build_setup with: - ref: refs/tags/${{ inputs.tag-name }} - - name: Grant execute permission for gradlew - run: chmod +x gradlew + ref: ${{ inputs.tag-name }} - name: Get Version id: ver - run: | - version=$(./gradlew -q printVersion) - printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT" + run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT - name: Build run: ./gradlew assemble - name: Upload Build Artifacts @@ -94,13 +89,13 @@ jobs: # - name: Download artifacts # uses: actions/download-artifact@v4 # with: -# name: build-artifacts-${{ inputs.tag-name }} +# name: build-artifacts-${{ inputs.branch }} # - name: Publish Mod # env: -# MC_VERSION: ${{ inputs.version == '1.21' && '1.21.1' || '26.1.2' }} -# LOADER: neoforge -# JAVA: ${{ inputs.version == '1.21' && '21' || '25' }} -# VERSION_TYPE: beta +# MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }} +# LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }} +# JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }} +# VERSION_TYPE: ${{ inputs.branch == '1.21' && 'beta' || 'beta' }} # uses: Kir-Antipov/mc-publish@v3.3.0 # with: # modrinth-id: aADDBrNC @@ -127,13 +122,13 @@ jobs: # - name: Download artifacts # uses: actions/download-artifact@v4 # with: -# name: build-artifacts-${{ inputs.tag-name }} +# name: build-artifacts-${{ inputs.branch }} # - name: Publish Mod # env: -# MC_VERSION: ${{ inputs.version == '1.21' && '1.21.1' || '26.1.2' }} -# LOADER: neoforge -# JAVA: ${{ inputs.version == '1.21' && '21' || '25' }} -# VERSION_TYPE: ${{ inputs.version == '1.21' && 'alpha' || 'beta' }} +# MC_VERSION: ${{ inputs.branch == '1.21' && '1.21.1' || '1.20.1' }} +# LOADER: ${{ inputs.branch == '1.21' && 'neoforge' || 'forge' }} +# JAVA: ${{ inputs.branch == '1.21' && '21' || '17' }} +# VERSION_TYPE: ${{ inputs.branch == '1.21' && 'alpha' || 'beta' }} # uses: Kir-Antipov/mc-publish@v3.3.0 # with: # curseforge-id: 1397216 @@ -153,8 +148,7 @@ jobs: bump-version-and-changelog: name: Bump Version and Build Changelog needs: [ build, upload-release-artifacts ] - concurrency: - group: release-update-${{ inputs.version }} + if: ${{ always() && !failure() && !cancelled() }} runs-on: ubuntu-latest permissions: contents: write @@ -162,50 +156,25 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: refs/heads/${{ inputs.version }} - fetch-depth: 0 + ref: ${{ inputs.version }} - name: Bump Version - env: - RELEASE_BRANCH: ${{ inputs.version }} - 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-$RELEASE_BRANCH" - current=$(sed -nE 's/^mod_version[[:blank:]]*=[[:blank:]]*(.*)$/\1/p' gradle.properties) - if [[ $current == "$RELEASE_VERSION" ]]; then - bumped=$(awk 'BEGIN { FS = OFS = "." } { $NF++; print }' <<< "$RELEASE_VERSION") - sed -i -E "s/^(mod_version[[:blank:]]*=[[:blank:]]*).*/\1$bumped/" gradle.properties - git commit -m "Bump version to $bumped" -- gradle.properties - fi + git switch -C gh/release-${{ inputs.version }} + BUMPED=$(echo ${{ needs.build.outputs.ver }} | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.) + sed -i "s/= ${{ needs.build.outputs.ver }}/= ${BUMPED}/" gradle.properties + git commit -am "Bump version to ${BUMPED}" - name: Prepend to CHANGELOG - if: inputs.changelog-body != '' + if: inputs.changelog-body env: CHANGELOG_BODY: ${{ inputs.changelog-body }} - RELEASE_VERSION: ${{ needs.build.outputs.ver }} run: | - if git grep -Fq "## Version [v$RELEASE_VERSION](" -- CHANGELOG.md; then - exit 0 - fi - { - head -n 2 CHANGELOG.md - printf '%s\n' "$CHANGELOG_BODY" - tail -n +3 CHANGELOG.md - } > changelog.tmp - mv changelog.tmp CHANGELOG.md - git commit -m 'Updated CHANGELOG' -- 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 }} - RELEASE_BRANCH: ${{ inputs.version }} run: | - if git diff --quiet "refs/remotes/origin/$RELEASE_BRANCH" HEAD; then - exit 0 - fi - pr_branch="gh/release-$RELEASE_BRANCH" - git push --force-with-lease origin "HEAD:refs/heads/$pr_branch" - pull_request=$(gh pr list --base "$RELEASE_BRANCH" --head "$pr_branch" --json number --jq '.[0].number // empty') - if [[ -z $pull_request ]]; then - gh pr create --base "$RELEASE_BRANCH" --head "$pr_branch" --title "RELEASE for $RELEASE_BRANCH [no-snapshot]" \ - --body 'Created by GH Workflow' --label 'ignore changelog' - fi + git push --force --set-upstream origin gh/release-${{ inputs.version }} + gh pr create -B ${{ inputs.version }} -H gh/release-${{ inputs.version }} --title "RELEASE for ${{ inputs.version }} [no-snapshot]" --body "Created by GH Workflow" --label "ignore changelog" diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 8fc1b38..f3debe9 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -6,33 +6,20 @@ on: paths: ['.github/**'] jobs: - sync-21: - name: Sync to 1.21 - concurrency: workflow-sync-1.21 + sync: runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write env: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 with: ref: '1.21' - fetch-depth: 0 - - name: Copy .github from 26.1 and open pull request - run: | + - run: | git config user.name 'github-actions[bot]' git config user.email '41898282+github-actions[bot]@users.noreply.github.com' - git switch -c gh/workflow-sync-1.21 - git restore --source=origin/26.1 --staged --worktree -- .github - if git diff --cached --quiet; then - exit 0 - fi - git commit -m 'Sync Workflows' - git push --force-with-lease origin HEAD:refs/heads/gh/workflow-sync-1.21 - pull_request=$(gh pr list --base 1.21 --head gh/workflow-sync-1.21 --json number --jq '.[0].number // empty') - if [[ -z $pull_request ]]; then - gh pr create --base 1.21 --head gh/workflow-sync-1.21 --title 'Sync Workflows with 26.1 [no-snapshot]' \ - --body 'Created by GH Workflow' --label 'ignore changelog' - fi + git switch -C gh/workflow-sync + git fetch origin + git checkout origin/26.1 -- .github + git commit -am "Sync Workflows" + git push --force --set-upstream origin gh/workflow-sync + gh pr create -B 1.21 -H gh/workflow-sync --title "Sync Workflows with 26.1 [no-snapshot]" --body "Created by GH Workflow" --label "ignore changelog" diff --git a/.github/workflows/update-gradle-cache.yml b/.github/workflows/update-gradle-cache.yml index 51fd9f7..b2716fd 100644 --- a/.github/workflows/update-gradle-cache.yml +++ b/.github/workflows/update-gradle-cache.yml @@ -22,7 +22,5 @@ jobs: uses: ./.github/actions/build_setup with: update-cache: true - - name: Grant execute permission for gradlew - run: chmod +x gradlew - name: Build Project with Gradle run: ./gradlew assemble --warning-mode all