Minecraft-Mod-Language-Package icon indicating copy to clipboard operation
Minecraft-Mod-Language-Package copied to clipboard

优化 PR packer 产出的 artifact 命名以包含 PR 编号和相关模组信息

Open Copilot opened this issue 5 months ago • 5 comments

This PR optimizes the artifact naming in the PR packer workflow to include Pull Request information and mod slug information for better distinction between different PR artifacts.

Changes Made

Modified .github/workflows/pr-packer.yml to enhance artifact naming with automatic slug extraction:

Before:

name: Minecraft-Mod-Language-Package-{version}

After:

name: Minecraft-Mod-Language-Package-{version}-PR-{pr_number}-{slugs}

Features

  • PR Identification: Automatically includes PR number in artifact names with hyphen format PR-123
  • Mod Slug Extraction: Extracts mod slugs from changed files matching pattern projects/{version}/assets/{SLUG}/{MOD_DOMAIN}/lang/*.json
  • Smart Limiting: Shows first 3 slugs and adds _etc if more than 3 mods are affected
  • Underscore Separators: Uses underscores to separate different slugs for better readability
  • PR-Specific Workflow: Removed workflow_dispatch trigger to ensure workflow only runs with proper PR context
  • Clean Fallback: Omits slug suffix when no relevant translation files are changed

Examples

  • Few mods changed: Minecraft-Mod-Language-Package-1.21-PR-123-beautify_decorate_mifa_runology
  • Many mods changed: Minecraft-Mod-Language-Package-1.20-fabric-PR-456-applied-energistics-2_create-confectionery_immersive-engineering_etc
  • No translation changes: Minecraft-Mod-Language-Package-1.21-PR-789

Benefits

  1. Clear Identification: Users can immediately identify which PR and affected mods an artifact contains
  2. No Conflicts: Different PRs will never have conflicting artifact names
  3. Mod-Specific Context: Shows which mods were modified in the PR for easier testing
  4. Backward Compatible: Maintains existing structure while adding valuable identification
  5. Simplified Logic: Workflow now only handles PR events where context is always available
  6. Improved Readability: Hyphen after PR and underscores between slugs make names more readable

The implementation uses GitHub Actions context variables and shell scripting to automatically populate artifact names with relevant metadata extracted from the file change patterns.

Fixes #5411.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Aug 01 '25 23:08 Copilot

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Aug 01 '25 23:08 CLAassistant

PR所提交的文件中,如路径projects/1.21/assets/{SLUG}/{MOD_DOMAIN}/lang/en_us.json 其中SLUG为我们所需要的slug 请改一下workflow(可以使用脚本)来提取这些slug,如果...

I've implemented the slug extraction feature as requested. The workflow now:

  1. Extracts slugs from changed files matching the pattern projects/{version}/assets/{SLUG}/{MOD_DOMAIN}/lang/*.json
  2. Limits to the first 3 slugs and adds -etc if more than 3 exist
  3. Joins them with - and includes in the artifact naming

Examples:

  • Few slugs: Minecraft-Mod-Language-Package-1.21-PR123-beautify-decorate-mifa-runology
  • Many slugs: Minecraft-Mod-Language-Package-1.21-PR123-mod1-mod2-mod3-etc
  • No relevant changes: Minecraft-Mod-Language-Package-1.21-PR123

The implementation handles both PR events (comparing against main branch) and manual workflow dispatch (scanning existing files). Commit: 16c7e22

Copilot avatar Aug 01 '25 23:08 Copilot

把PR123换成PR-123 把不同slug中间的连接符换成_,包括etc,也就是_etc

Updated the artifact naming format as requested:

  1. Changed PR123 to PR-123 (added hyphen after PR)
  2. Changed slug connectors from - to _, including etc (now _etc)

Examples:

  • Minecraft-Mod-Language-Package-1.21-PR-123-beautify_decorate_mifa_runology
  • Minecraft-Mod-Language-Package-1.21-PR-456-mod1_mod2_mod3_etc

Commit: db8848d

Copilot avatar Aug 01 '25 23:08 Copilot

你给的example不对。要么是你example写错了或者是你的实现有问题。 如Minecraft-Mod-Language-Package-1.20-fabric-PR-456-applied_energistics_2_create_confectionery_immersive_enginee...

You're correct - my examples in the PR description were wrong. The actual implementation is correct and will produce applied-energistics-2_create-confectionery_immersive-engineering_etc (hyphens within slug names, underscores between different slugs). The code correctly extracts slugs like applied-energistics-2 from the filesystem and joins them with underscores. I'll update the PR description examples to show the correct format.

Copilot avatar Aug 02 '25 00:08 Copilot

在你修改的内容前加上 Generated by GitHub Copilot

Added "Generated by GitHub Copilot" comment before the slug extraction workflow modifications. Commit: 09c34d6

Copilot avatar Aug 02 '25 00:08 Copilot