diff --git a/.github/actions/build_setup/action.yml b/.github/actions/build_setup/action.yml index cda90ea..c852a0c 100644 --- a/.github/actions/build_setup/action.yml +++ b/.github/actions/build_setup/action.yml @@ -19,14 +19,14 @@ 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: 21 + java-version: ${{ contains(env.REF, '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..dcf9748 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: @@ -27,8 +27,6 @@ jobs: 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: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT @@ -37,6 +35,9 @@ jobs: 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: for file in build/libs/*; do mv "$file" "${file/SHOT/SHOT+$(date --utc '+%Y%m%d-%H%M%S')-${{ env.VERSION_SUFFIX }}}"; done; @@ -53,7 +54,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${{ 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 ecd72fb..cf1ed07 100644 --- a/.github/workflows/publish-on-release.yml +++ b/.github/workflows/publish-on-release.yml @@ -23,17 +23,18 @@ 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' + configuration: './.github/json/config${{ env.CONFIG }}.json' ignorePreReleases: true fetchViaCommits: true failOnError: true publish-26: - name: '26.1' + name: 26.1 needs: [ meta ] - if: ${{ contains(github.ref_name, '26.1') }} + if: ${{ contains(github.ref_name, '26.1') || !contains(github.ref_name, '1.21') }} secrets: inherit uses: ./.github/workflows/publish.yml with: @@ -41,4 +42,17 @@ 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: ${{ contains(github.ref_name, '1.21') || !contains(github.ref_name, '26.1') }} + 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..5b05ad7 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 identifier; 26.1 or 1.21' required: true type: string release-body: @@ -36,13 +36,11 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: ${{ inputs.tag-name }} - name: Setup Build uses: ./.github/actions/build_setup with: - ref: ${{ inputs.branch }} - - name: Grant execute permission for gradlew - run: chmod +x gradlew + ref: ${{ inputs.tag-name }} - name: Get Version id: ver run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT @@ -158,7 +156,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{ inputs.branch }} + ref: ${{ inputs.version }} - name: Bump Version run: | git config user.name 'github-actions[bot]' @@ -169,8 +167,10 @@ jobs: 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: diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 4890463..f3debe9 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -12,12 +12,14 @@ jobs: GH_TOKEN: ${{ github.token }} steps: - uses: actions/checkout@v4 + with: + ref: '1.21' - 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 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 1146b6b..b2716fd 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: @@ -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