From a5cdd34a97f74bf5bba5749b76d3cbc6707fafd3 Mon Sep 17 00:00:00 2001 From: qiuye2024github Date: Thu, 9 Apr 2026 18:31:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 47 +++++ .github/ISSUE_TEMPLATE/000-bug-report.yml | 113 +++++++++++ .../ISSUE_TEMPLATE/001-feature-request.yml | 29 +++ .github/ISSUE_TEMPLATE/config.yml | 5 + .github/actions/build_setup/action.yml | 32 ++++ .github/json/config-latest.json | 35 ++++ .github/json/config.json | 45 +++++ .github/labeler.yml | 3 + .github/pull_request_template.md | 26 +++ .github/release.yml | 26 +++ .github/workflows/auto-build.yml | 71 +++++++ .github/workflows/build-on-push.yml | 54 ++++++ .github/workflows/clean.yml | 20 ++ .github/workflows/format-java.yml | 41 ++++ .github/workflows/labeler.yml | 12 ++ .github/workflows/manage-issue-labels.yml | 23 +++ .github/workflows/manage-pr-labels.yml | 43 +++++ .github/workflows/publish-on-release.yml | 44 +++++ .github/workflows/publish.yml | 180 ++++++++++++++++++ .github/workflows/sync.yml | 22 +++ .github/workflows/test-on-push.yml | 62 ++++++ .github/workflows/update-gradle-cache.yml | 28 +++ 22 files changed, 961 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/ISSUE_TEMPLATE/000-bug-report.yml create mode 100644 .github/ISSUE_TEMPLATE/001-feature-request.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/actions/build_setup/action.yml create mode 100644 .github/json/config-latest.json create mode 100644 .github/json/config.json create mode 100644 .github/labeler.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/release.yml create mode 100644 .github/workflows/auto-build.yml create mode 100644 .github/workflows/build-on-push.yml create mode 100644 .github/workflows/clean.yml create mode 100644 .github/workflows/format-java.yml create mode 100644 .github/workflows/labeler.yml create mode 100644 .github/workflows/manage-issue-labels.yml create mode 100644 .github/workflows/manage-pr-labels.yml create mode 100644 .github/workflows/publish-on-release.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/sync.yml create mode 100644 .github/workflows/test-on-push.yml create mode 100644 .github/workflows/update-gradle-cache.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..44440af --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,47 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "Docs Codespace", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "workspaceMount": "source=${localWorkspaceFolder},target=/modern,type=bind", + "workspaceFolder": "/modern/docs", + "features": { + "ghcr.io/devcontainers/features/python:1": { + "installTools": true, + "version": "3.11" + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [8000], + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "settings": { + "yaml.schemas": { + "https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml" + }, + "yaml.customTags": [ + "!ENV scalar", + "!ENV sequence", + "tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg", + "tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji", + "tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format" + ], + "git.openRepositoryInParentFolders": "always", + "git.autofetch": "all", + "git.autoStash": true + }, + "extensions": ["redhat.vscode-yaml"] + } + } + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} + diff --git a/.github/ISSUE_TEMPLATE/000-bug-report.yml b/.github/ISSUE_TEMPLATE/000-bug-report.yml new file mode 100644 index 0000000..126b7a7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/000-bug-report.yml @@ -0,0 +1,113 @@ +name: Bug Report / 错误报告 +description: Report a bug where something is not working as expected. / 报告某物未按预期工作的错误。 +labels: [ "type: bug" ] +body: + - type: checkboxes + id: existing-issue + attributes: + label: Checked for existing issues / 已检查现有问题 + description: You have checked for existing reports of this issue, open or closed. / 您已检查过此问题的现有报告(开放或已关闭)。 + options: + - label: "I have checked for existing issues, and have found none. / 我已检查现有问题,未发现相同报告。" + required: true + - type: checkboxes + id: tried-latest + attributes: + label: Tested latest version / 已测试最新版本 + description: You have checked that this issue occurs on the latest version of Mekanism Extras. / 您已确认此问题在 Mekanism Extras 的最新版本中出现。 + options: + - label: "I have checked that this occurs on the latest version. / 我已确认此问题在最新版本中出现。" + required: true + - type: input + id: mekanismextras-version + attributes: + label: SyncedData Version / SyncedData 版本 + description: The version of SyncedData you were using when this bug was encountered. If you do not know where to find this, look for the mod jar file in the mods folder, or in the mods viewer in-game. / 遇到此错误时使用的 SyncedData 版本。如果不知道如何查找,请查看 mods 文件夹中的 mod jar 文件,或游戏内的模组查看器。 + placeholder: "Example: v2.3.4 / 例如:v2.3.4" + validations: + required: true + - type: dropdown + id: mc-version + attributes: + label: Minecraft Version / Minecraft 版本 + description: The version of Minecraft you were using when this bug was encountered. If you do not know where to find this, it is in the bottom left of the main menu. Any version not listed is not supported. / 遇到此错误时使用的 Minecraft 版本。如果不知道如何查找,它位于主菜单的左下角。未列出的任何版本均不受支持。 + options: + - "26.1 NeoForge" + validations: + required: true + - type: dropdown + id: recipe-viewer + attributes: + label: Recipe Viewer Installed + description: The recipe viewer installed. + options: + - "JEI" + - "REI" + - "EMI" + validations: + required: false + - type: dropdown + id: environment + attributes: + label: Environment / 环境 + description: How you were playing on the world. Hybrid servers are unsupported. / 您在世界中游玩的方式。不支持混合服务器。 + options: + - "Singleplayer / 单人游戏" + - "Multiplayer - Open to LAN / 多人游戏 - 开放局域网" + - "Multiplayer - Dedicated Server / 多人游戏 - 专用服务器" + validations: + required: true + - type: dropdown + id: cross-mod + attributes: + label: Cross-Mod Interaction / 跨模组交互 + description: Does this bug occur because of another mod installed alongside Mekanism Extras? / 此错误是否由于与 Mekanism Extras 同时安装的其他模组引起? + options: + - "Yes / 是" + - "No / 否" + - "Unsure / 不确定" + validations: + required: true + - type: textarea + id: other-mods + attributes: + label: Other Installed Mods / 其他已安装模组 + description: Enter the name of the modpack you're playing, or list all mods you have installed here. / 输入您正在游玩的整合包名称,或在此处列出所有已安装的模组。 + placeholder: "Example: Cosmic Frontiers, Monifactory, Embeddium, NuclearCraft Neoteric, AE2,... / 例如:Cosmic Frontiers, Monifactory, Embeddium, NuclearCraft Neoteric, AE2,..." + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected Behavior / 预期行为 + description: What you expected to happen. Attach screenshots here as necessary. / 您期望发生什么。必要时在此处附加截图。 + placeholder: "Example: Expected to produce X by consuming Y. / 例如:期望通过消耗 Y 来生产 X。" + validations: + required: true + - type: textarea + id: result + attributes: + label: Actual Behavior / 实际行为 + description: What happened despite your expectations. Attach screenshots here as necessary. / 与您预期不符的实际发生情况。必要时在此处附加截图。 + placeholder: "Example: Produced one X but Y was not consumed. / 例如:生产了一个 X 但 Y 未被消耗。" + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Steps to Reproduce / 重现步骤 + description: How to reproduce the bug. / 如何重现此错误。 + placeholder: "Example: 1) I did X... / 例如:1) 我做了 X..." + validations: + required: true + - type: textarea + id: additional-info + attributes: + label: Additional Information / 附加信息 + description: Any additional information you wish to provide. Please add anything which did not fit into the other sections here. / 您希望提供的任何附加信息。请将不适合其他部分的内容添加在此处。 + placeholder: "Example: This is likely caused by X because... / 例如:这很可能由 X 引起,因为..." + validations: + required: false + - type: markdown + attributes: + value: Thank you for taking the time to fill out this bug report. / 感谢您抽出时间填写此错误报告。 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/001-feature-request.yml b/.github/ISSUE_TEMPLATE/001-feature-request.yml new file mode 100644 index 0000000..883702c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/001-feature-request.yml @@ -0,0 +1,29 @@ +name: Feature Request / 功能请求 +description: Request a new feature. / 请求新功能。 +labels: [ "type: feature" ] +body: + - type: input + id: cross-mod + attributes: + label: Cross-mod Integration / 跨模组集成 + description: "Does this feature involve integration with another mod? If so specify the mod(s). Otherwise, leave this blank. / 此功能是否涉及与其他模组的集成?如果是,请指定模组名称。否则留空。" + placeholder: "Example: Create Mod / 例如:Create Mod" + - type: dropdown + id: mc-version + attributes: + label: Minecraft Version / Minecraft 版本 + description: The version of Minecraft you wish this feature was added for. / 您希望此功能添加到的 Minecraft 版本。 + options: + - "Both" + - "26.1 NeoForge" + - type: textarea + id: description + attributes: + label: Feature Description / 功能描述 + description: "What feature would you like to have? Please describe it here. / 您希望拥有什么功能?请在此描述。" + placeholder: "Example: I want to be able to do... / 例如:我希望能够做..." + validations: + required: true + - type: markdown + attributes: + value: Thank you for taking the time to fill out this feature request. / 感谢您抽出时间填写此功能请求。 \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..e4c90c4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: Discord / Discord 服务器 + url: https://discord.gg/KqQx9DEJGm + about: Join us on Discord to chat, discuss the game, and more. For bug reports, please use GitHub issues. / 加入我们的 Discord 服务器来闲聊、讨论游戏等。错误报告请使用 GitHub issues。 \ No newline at end of file diff --git a/.github/actions/build_setup/action.yml b/.github/actions/build_setup/action.yml new file mode 100644 index 0000000..c1bf4ed --- /dev/null +++ b/.github/actions/build_setup/action.yml @@ -0,0 +1,32 @@ +name: Build Setup +description: Setup for standard Java builds + +inputs: + update-cache: + description: If cache should be updated + required: false + default: 'false' + ref: + description: 'Ref to checkout' + required: false + +runs: + using: 'composite' + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref || github.ref }} + - name: Set up JDK + uses: actions/setup-java@v4 + env: + REF: ${{ inputs.ref || github.ref }} + with: + distribution: temurin + java-version: 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' }} + add-job-summary: 'on-failure' diff --git a/.github/json/config-latest.json b/.github/json/config-latest.json new file mode 100644 index 0000000..85b09dc --- /dev/null +++ b/.github/json/config-latest.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\\.]+(-26\\.1)?$).+$", + "flags": "gu" + }, + "transformer": { + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" + } + }, + "max_pull_requests": 1000, + "max_back_track_time_days": 365, + "base_branches": ["1.20.1"] +} \ No newline at end of file diff --git a/.github/json/config.json b/.github/json/config.json new file mode 100644 index 0000000..19f3993 --- /dev/null +++ b/.github/json/config.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\\.]+(-26\\.1)?$).+$", + "flags": "gu" + }, + "transformer": { + "pattern": "v?([0-9\\.]+)(-[0-9\\.]+)?", + "target": "$1" + } + }, + "max_pull_requests": 1000, + "max_back_track_time_days": 365, + "base_branches": ["1.20.1"] +} \ No newline at end of file diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..26bb812 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,3 @@ +# https://github.com/github/issue-labeler#usage +26.1: + - '/^26\.1 NeoForge$/m' \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..e4d6702 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,26 @@ +## What / 目的 +_This section describes what this PR is about. It should be a clear and concise description concerning what this PR is for, why this PR is needed, and why it should be accepted._ +_Linking an issue can be used alternatively to writing a description._ +_此部分描述该 PR 的内容。它应清晰简洁地说明该 PR 的目的、必要性以及为何应该被接受。_ +_也可以通过链接相关 Issue 来替代描述。_ + +## Implementation Details / 实现细节 +_Any implementations in this PR that should be carefully looked over, or that could/should have alternate solutions proposed._ +_本 PR 中任何需要仔细审查的实现细节,或者可能/应该提出替代解决方案的部分。_ + +## Outcome / 结果 +_A short description of what this PR added/fixed/changed/removed._ +_For correct linking of issues please use any of the Closes/Fixes/Resolves keywords. Example: When a PR is fixing a bug use "Fixes: #number-of-bug"_ +_简要描述此 PR 添加/修复/更改/删除了什么。_ +_为了正确链接 Issue,请使用 Closes/Fixes/Resolves 等关键词。例如:当 PR 修复一个 bug 时,使用 "Fixes: #bug编号"_ + +## Additional Information / 附加信息 +_This section is for screenshots to demonstrate any GUI or rendering changes, or any other additional information that reviewers should be aware of._ +_此部分用于放置展示 GUI 或渲染更改的截图,或任何其他审阅者应了解的其他信息。_ + +## Potential Compatibility Issues / 潜在兼容性问题 +_This section is for defining possible compatibility issues. It must be used when there are API changes, item/block/material/machine changes, or recipe changes._ +_此部分用于定义可能的兼容性问题。当存在 API 更改、物品/方块/材料/机器更改或配方更改时,必须使用此部分。_ + +**Please fill in as much useful information as possible. Also, please remove all unused sections, including this and the other explanations.** +**请尽可能填写有用的信息。同时,请删除所有未使用的部分,包括此说明和其他解释。** \ No newline at end of file diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..3f89d47 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,26 @@ +changelog: + + exclude: + labels: + - "ignore changelog" + + categories: + - title: New Features + labels: + - "type: feature" + + - title: Bug Fixes + labels: + - "type: bug" + + - title: Internal Changes + labels: + - "type: refactor" + + - title: Translation Changes + labels: + - "type: translation" + + - title: Other Changes + labels: + - "*" diff --git a/.github/workflows/auto-build.yml b/.github/workflows/auto-build.yml new file mode 100644 index 0000000..cdedd34 --- /dev/null +++ b/.github/workflows/auto-build.yml @@ -0,0 +1,71 @@ +name: Latest Build + +on: + push: + branches: ['26.1'] + paths: ['src/**', '**/*.gradle', 'gradle.properties'] + +concurrency: + group: auto-build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + 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 }} + SNAPSHOT: true + CI: true + permissions: + contents: write + 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: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT + - name: Version Suffix + id: suffix + run: echo "VERSION_SUFFIX=$(echo "${{ github.sha }}" | cut -c 1-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; + - name: Upload Artifacts + if: ${{ env.PUBLISH == 'true' }} + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: build/libs/* + if-no-files-found: error + retention-days: 90 + - name: Changelog + id: changelog + if: ${{ env.PUBLISH == 'true' }} + uses: mikepenz/release-changelog-builder-action@v5 + with: + configuration: "./.github/json/config-latest.json" + toTag: ${{ github.ref }} + fetchViaCommits: true + failOnError: false + - name: Release Latest + if: ${{ env.PUBLISH == 'true' }} + uses: andelf/nightly-release@46e2d5f80828ecc5c2c3c819eb31186a7cf2156c + with: + tag_name: latest-${{ github.ref_name }} + name: '${{ github.ref_name }}-${{ steps.ver.outputs.version}} SNAPSHOT ${{ env.VERSION_SUFFIX }}' + prerelease: true + body: | + The latest build of GTMoreMachine for Minecraft ${{ github.ref_name }}. + Please report any [issues](https://github.com/QiuYe-123/GTMoreMachine/issues). + ${{ steps.changelog.outputs.changelog }} + files: build/libs/*.jar diff --git a/.github/workflows/build-on-push.yml b/.github/workflows/build-on-push.yml new file mode 100644 index 0000000..accf677 --- /dev/null +++ b/.github/workflows/build-on-push.yml @@ -0,0 +1,54 @@ +name: Build pull request on push + +on: + pull_request: + paths: ['**'] + +# Cancel previous jobs if PR gets another push +concurrency: + group: PR-build-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + env: + VERSION_SUFFIX: "PR-${{ github.event.number }}" + steps: + - uses: actions/checkout@v4 + - name: Check Path Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'src/**' + - '*.gradle' + - 'gradle.properties' + - 'gradlew*' + - 'gradle/**' + - name: Setup Build + if: steps.filter.outputs.code == 'true' + uses: ./.github/actions/build_setup + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build + if: steps.filter.outputs.code == 'true' + run: ./gradlew assemble + - name: Rename Jars + if: steps.filter.outputs.code == 'true' + run: for file in build/libs/*; do mv "$file" "${file/.jar/-${{ env.VERSION_SUFFIX }}.jar}"; done; + - name: Upload All Artifacts + if: steps.filter.outputs.code == 'true' + uses: actions/upload-artifact@v4.0.0 + with: + name: Full Package + path: build/libs/* + retention-days: 15 + - name: Upload Main Jar + if: steps.filter.outputs.code == 'true' + uses: actions/upload-artifact@v4.0.0 + with: + name: Main Jar + path: build/libs/*[0-9]-PR-*.jar + retention-days: 15 diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..8e35795 --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,20 @@ +name: Clean Gradle + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + - name: Setup Build + uses: ./.github/actions/build_setup + with: + update-cache: true + - name: Make gradlew executable + run: chmod +x ./gradlew + - name: Clean + run: ./gradlew clean diff --git a/.github/workflows/format-java.yml b/.github/workflows/format-java.yml new file mode 100644 index 0000000..2abb8cd --- /dev/null +++ b/.github/workflows/format-java.yml @@ -0,0 +1,41 @@ +# Runs formatting requirements +name: Java Formatting + +on: + push: + branches: ['26.1'] + paths: ['src/main/java/**', 'src/test/**'] + pull_request: + paths: ['**'] + +concurrency: + group: formatting-${{ github.ref }} + cancel-in-progress: true + +jobs: + formatting: + name: Formatting + runs-on: ubuntu-latest + permissions: + pull-requests: read + steps: + - name: Checkout Repository + 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: Check Path Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'src/main/java/**' + - 'src/test/**' + - name: Setup Build + if: steps.filter.outputs.code == 'true' + uses: ./.github/actions/build_setup + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run Spotless Formatting Check with Gradle + if: steps.filter.outputs.code == 'true' + run: ./gradlew spotlessCheck --warning-mode all diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..48cbd8b --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: Label PRs + +on: + - pull_request_target + +jobs: + labeler: + permissions: + pull-requests: write + contents: read + uses: ModularMCLib/GithubActions/.github/workflows/labeler.yml@main + secrets: inherit diff --git a/.github/workflows/manage-issue-labels.yml b/.github/workflows/manage-issue-labels.yml new file mode 100644 index 0000000..ec7b5cd --- /dev/null +++ b/.github/workflows/manage-issue-labels.yml @@ -0,0 +1,23 @@ +# Manages labels on new issues +name: Issue Labels + +on: + issues: + types: [opened] + +permissions: + issues: write + contents: read + +jobs: + labels: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: '26.1' + sparse-checkout: '.github/labeler.yml' + - uses: github/issue-labeler@v3.3 + with: + configuration-path: .github/labeler.yml + enable-versioned-regex: 0 diff --git a/.github/workflows/manage-pr-labels.yml b/.github/workflows/manage-pr-labels.yml new file mode 100644 index 0000000..80c2e0c --- /dev/null +++ b/.github/workflows/manage-pr-labels.yml @@ -0,0 +1,43 @@ +# Manages labels on PRs before allowing merging +name: Pull Request Labels + +# Checks for label once PR has been reviewed or label is applied +on: + pull_request: + types: [opened, labeled, unlabeled] + +concurrency: + group: pr-labels-${{ github.head_ref }} + cancel-in-progress: true + +jobs: + labels: + name: Label Check + runs-on: ubuntu-latest + permissions: + pull-requests: read # needed to utilize required-labels + steps: + - name: Check for Merge-Blocking Labels # blocks merge if present + uses: mheap/github-action-required-labels@v5 + with: + mode: exactly + count: 0 + labels: 'do not merge, admin merge' + exit_type: failure + + - name: Check for Required Type Labels # require at least one of these labels + uses: mheap/github-action-required-labels@v5 + with: + mode: minimum + count: 1 + labels: 'type: feature, type: bugfix, type: refactor, type: translation, type: tests, ignore changelog' + exit_type: failure + + - name: Check for Required Release Label # require exactly one of these labels + uses: mheap/github-action-required-labels@v5 + with: + mode: exactly + count: 1 + labels: 'release: api - X.0.0, release: major - 0.X.0, release: Patch - 0.0.X, release: stale' + exit_type: failure + diff --git a/.github/workflows/publish-on-release.yml b/.github/workflows/publish-on-release.yml new file mode 100644 index 0000000..99b86e3 --- /dev/null +++ b/.github/workflows/publish-on-release.yml @@ -0,0 +1,44 @@ +name: Publish on Release + +on: + release: + types: [released] + +jobs: + meta: + name: Metadata + runs-on: ubuntu-latest + outputs: + CHANGELOG: ${{ steps.changelog.outputs.changelog }} + permissions: + contents: write + pull-requests: read + steps: + - name: Get Config + uses: actions/checkout@v4 + with: + ref: ${{ github.ref_name }} + 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' + ignorePreReleases: true + fetchViaCommits: true + failOnError: true + + publish-26: + name: '26.1' + needs: [ meta ] + if: ${{ 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 }} + branch: '26.1' + release-body: ${{ github.event.release.body }} + changelog-body: ${{ needs.meta.outputs.CHANGELOG }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..e24dec0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,180 @@ +name: Publish Version + +on: + workflow_call: + inputs: + simulate: + required: false + type: boolean + tag-name: + description: 'Tag to build from and upload to' + required: true + type: string + version: + description: 'Version identifier;' + required: true + type: string + release-body: + description: 'Body for published release notes' + required: false + type: string + changelog-body: + description: 'Body of change notes to insert into CHANGELOG.md' + required: false + type: string + +jobs: + build: + name: Build and Publish to Maven + runs-on: ubuntu-latest + permissions: + contents: write + env: + CI: 'true' + outputs: + ver: ${{ steps.ver.outputs.version }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Setup Build + uses: ./.github/actions/build_setup + with: + ref: ${{ inputs.branch }} + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Get Version + id: ver + run: echo "version=$(./gradlew -q printVersion)" >> $GITHUB_OUTPUT + - name: Build + run: ./gradlew assemble + - name: Upload Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts-${{ inputs.branch }} + path: build/libs/* + if-no-files-found: error + retention-days: 3 + - name: Publish + if: ${{ !inputs.simulate }} + env: + MAVEN_USER: ${{ secrets.MAVEN_USER }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + run: ./gradlew publish + + upload-release-artifacts: + name: Upload Artifacts + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts-${{ inputs.tag-name }} + - name: Upload artifacts to release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ inputs.tag-name }} + files: ./*.jar + fail_on_unmatched_files: true + +# publish-modrinth: +# name: Publish to Modrinth +# 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' && 'beta' || 'beta' }} +# uses: Kir-Antipov/mc-publish@v3.3.0 +# with: +# modrinth-id: aADDBrNC +# modrinth-token: ${{ secrets.MODRINTH_TOKEN }} +# files: | +# ./gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar +# ./!(gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar) +# name: 'GTMoreMachine ${{ 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: 1397216 +# curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} +# files: | +# ./gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar +# ./!(gtmoremachine-${{ env.MC_VERSION }}-${{ needs.build.outputs.ver }}.jar) +# name: 'GTMoreMachine ${{ 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 + + # After successful release, PR version bump and changelog + bump-version-and-changelog: + name: Bump Version and Build Changelog + needs: [ build, upload-release-artifacts ] + if: ${{ always() && !failure() && !cancelled() }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Bump Version + 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}" + - name: Prepend to CHANGELOG + if: 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 + git commit -am "Updated CHANGELOG" + - name: Push and PR + env: + GH_TOKEN: ${{ github.token }} + 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" diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000..819a49c --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,22 @@ +name: Sync Github Folder + +on: + push: + branches: ['26.1'] + paths: ['.github/**'] + +jobs: + sync: + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + - 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 commit -am "Sync Workflows" + git push --force --set-upstream origin gh/workflow-sync diff --git a/.github/workflows/test-on-push.yml b/.github/workflows/test-on-push.yml new file mode 100644 index 0000000..871ebe2 --- /dev/null +++ b/.github/workflows/test-on-push.yml @@ -0,0 +1,62 @@ +name: Test pull request on push + +on: + pull_request: + paths: ['**'] + +# Cancel previous jobs if PR gets another push +concurrency: + group: PR-test-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + env: + VERSION_SUFFIX: "PR-${{ github.event.number }}" + steps: + - uses: actions/checkout@v4 + - name: Check Path Filter + uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + code: + - 'src/**' + - '*.gradle' + - 'gradle.properties' + - 'gradlew*' + - 'gradle/**' + - name: Setup Build + if: steps.filter.outputs.code == 'true' + uses: ./.github/actions/build_setup + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Run GameTests + if: steps.filter.outputs.code == 'true' + id: gametest + continue-on-error: true + run: ./gradlew runGameTestServer + - name: Update “Tests Passed” / “Tests Failed” labels + if: steps.filter.outputs.code == 'true' && github.event.pull_request.head.repo.full_name == github.repository + uses: actions/github-script@v7 + with: + script: | + const [add, remove] = { + success: ['Tests: Passed','Tests: Failed'], + failure: ['Tests: Failed','Tests: Passed'] + }['${{ steps.gametest.outcome }}']; + + const { owner, repo } = context.repo; + const issue_number = context.payload.pull_request.number; + + await github.rest.issues + .addLabels({ owner, repo, issue_number, labels: [add] }) + .catch(() => {}); + + await github.rest.issues + .removeLabel({ owner, repo, issue_number, name: remove }) + .catch(() => {}); + - name: Fail on GameTest failures + if: steps.filter.outputs.code == 'true' && steps.gametest.outcome == 'failure' + run: exit 1 \ No newline at end of file diff --git a/.github/workflows/update-gradle-cache.yml b/.github/workflows/update-gradle-cache.yml new file mode 100644 index 0000000..1146b6b --- /dev/null +++ b/.github/workflows/update-gradle-cache.yml @@ -0,0 +1,28 @@ +# Updates the Gradle Cache when necessary +name: Update Gradle Cache + +on: + push: + branches: ['26.1'] + paths: ['gradle/**', '**/*.gradle', 'gradle.properties', 'gradlew*', 'src/main/resources/META-INF/accesstransformer.cfg'] + workflow_dispatch: + +concurrency: + group: gradle-cache-${{ github.ref }} + cancel-in-progress: true + +jobs: + update-cache: + name: Update Grade Cache + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Setup Build + 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