From 7ba5b0f59a0726d352ec09e02bc8d53ca87d72d5 Mon Sep 17 00:00:00 2001 From: kross <135918757+krossgg@users.noreply.github.com> Date: Sun, 10 Nov 2024 15:56:42 -0500 Subject: [PATCH] Workflow Separation (#2300) --- .github/json/config-1.21.json | 45 ++++++++++++++++++++++++ .github/json/config-latest.json | 5 +-- .github/json/config.json | 20 ++++++++--- .github/workflows/manage-pr-labels.yml | 4 ++- .github/workflows/publish-on-release.yml | 8 ++--- .github/workflows/publish.yml | 40 ++++++++++++++++++--- 6 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 .github/json/config-1.21.json diff --git a/.github/json/config-1.21.json b/.github/json/config-1.21.json new file mode 100644 index 0000000000..1162d06b54 --- /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": 90, + "base_branches": ["1.21"] +} diff --git a/.github/json/config-latest.json b/.github/json/config-latest.json index 34a6f70b0f..de302dc8b2 100644 --- a/.github/json/config-latest.json +++ b/.github/json/config-latest.json @@ -14,9 +14,10 @@ } ], "sort": "ASC", - "template": "## What's Changed\n#{{CHANGELOG}}", + "template": "## What's Changed\n#{{CHANGELOG}}\n#{{UNCATEGORIZED}}", "pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})", + "empty_template": "", "ignore_labels": ["ignore changelog"], "max_pull_requests": 1000, - "max_back_track_time_days": 90 + "max_back_track_time_days": 30 } diff --git a/.github/json/config.json b/.github/json/config.json index 86d9143508..2737ea278f 100644 --- a/.github/json/config.json +++ b/.github/json/config.json @@ -14,19 +14,29 @@ } ], "sort": "ASC", - "template": "## Version [#{{TO_TAG}}](#{{RELEASE_DIFF}})\n#{{CHANGELOG}} ", + "template": "## Version [v#{{VERSION}}](#{{RELEASE_DIFF}})\n#{{CHANGELOG}} ", "pr_template": "- #{{TITLE}} by @#{{AUTHOR}} in [##{{NUMBER}}](#{{URL}})", - "empty_template": "- No changes", + "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?(1\\.20\\.1-)?[0-9\\.]+$).+$", + "pattern": "^(?!v?[0-9\\.]+(-1\\.20\\.1)?$).+$", "flags": "gu" }, "transformer": { - "pattern": "v?([0-9\\.]+-)?([0-9\\.]+)", - "target": "$2" + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" } }, "max_pull_requests": 1000, diff --git a/.github/workflows/manage-pr-labels.yml b/.github/workflows/manage-pr-labels.yml index 5757945724..2e983e807a 100644 --- a/.github/workflows/manage-pr-labels.yml +++ b/.github/workflows/manage-pr-labels.yml @@ -1,10 +1,12 @@ # Manages labels on PRs before allowing merging name: Pull Request Labels -# Checks for label once PR has been reviewed +# Checks for label once PR has been reviewed or label is applied on: pull_request_review: types: [submitted] + pull_request: + types: [labeled] concurrency: group: pr-labels-${{ github.head_ref }} diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml index ef7c8f892f..71ee87efa4 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -4,8 +4,6 @@ on: release: types: [released] -# TODO: Make it so you can publish releases for each mc-ver individually - jobs: meta: name: Metadata @@ -25,10 +23,10 @@ jobs: id: changelog env: GITHUB_TOKEN: ${{ github.token }} + CONFIG: ${{ contains(github.ref_name, '1.21') && '-1.21' || '' }} uses: mikepenz/release-changelog-builder-action@v5 with: - configuration: ./.github/json/config.json - toTag: ${{ github.event.release.tag }} + configuration: './.github/json/config${{ env.CONFIG }}.json' ignorePreReleases: true fetchViaCommits: true failOnError: true @@ -36,6 +34,7 @@ jobs: publish-20: name: 1.20.1 needs: [ meta ] + if: ${{ contains(github.ref_name, '1.20.1') || !contains(github.ref_name, '1.21') }} secrets: inherit uses: ./.github/workflows/publish.yml with: @@ -48,6 +47,7 @@ jobs: publish-21: name: 1.21.1 needs: [ meta ] + if: ${{ contains(github.ref_name, '1.21') || !contains(github.ref_name, '1.20.1') }} secrets: inherit uses: ./.github/workflows/publish.yml with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 89f4bc1fed..847d470ac3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -76,8 +76,8 @@ jobs: files: ./*.jar fail_on_unmatched_files: true - publish-cf-modrinth: - name: Publish Mod + publish-modrinth: + name: Publish to Modrinth needs: build if: ${{ !inputs.simulate }} runs-on: ubuntu-latest @@ -93,10 +93,42 @@ jobs: 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: modrinth-id: 7tG215v7 modrinth-token: ${{ secrets.MODRINTH_TOKEN }} + files: | + ./gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar + ./!(gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar) + name: 'GregTechCEu ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}' + version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}' + version-type: ${{ env.VERSION_TYPE }} + changelog: ${{ inputs.release-body }} + loaders: ${{ env.LOADER }} + java: ${{ env.JAVA }} + fail-mode: fail + + publish-cf: + name: Publish to CF + needs: build + if: ${{ !inputs.simulate }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.branch }} + - 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' }} + uses: Kir-Antipov/mc-publish@v3.3.0 + with: curseforge-id: 890405 curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} files: | @@ -104,7 +136,7 @@ jobs: ./!(gtceu-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar) name: 'GregTechCEu ${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}' version: 'mc${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}' - version-type: beta + version-type: ${{ env.VERSION_TYPE }} changelog: ${{ inputs.release-body }} loaders: ${{ env.LOADER }} java: ${{ env.JAVA }} @@ -113,7 +145,7 @@ jobs: # After successful release, PR version bump and changelog bump-version-and-changelog: name: Bump Version and Build Changelog - needs: [ build, upload-release-artifacts, publish-cf-modrinth ] + needs: [ build, upload-release-artifacts, publish-modrinth, publish-cf] if: ${{ always() && !failure() && !cancelled() }} runs-on: ubuntu-latest permissions: