publish-flutter-package
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePublish Flutter Package
发布Flutter包
This skill automates the Flutter package release workflow triggered by git tags.
本Skill可通过Git标签触发,自动化Flutter包的发布工作流。
Workflow
工作流
0. Pre-check
0. 预检查
0.1 Project Root
0.1 项目根目录
Verify that the current working directory is the root of the Git repository (contains a folder and the main ).
.gitpubspec.yaml- If not at the root (e.g., inside a sub-package directory), advise the user to switch to the project root directory before proceeding to ensure and workspace configurations can be correctly identified.
.github/workflows
验证当前工作目录是否为Git仓库的根目录(包含文件夹和主文件)。
.gitpubspec.yaml- 如果不在根目录(例如,位于子包目录中),建议用户切换到项目根目录后再继续,以确保能正确识别和工作区配置。
.github/workflows
0.2 Detect Packages (Workspace Support)
0.2 检测包(支持工作区)
Read the root file.
pubspec.yaml- Check for the field.
workspace: - If present, parse the paths (e.g., ) to find all nested packages.
- pkgs/* - Ask the user which package to publish if multiple are detected.
读取根目录下的文件。
pubspec.yaml- 检查是否存在字段。
workspace: - 如果存在,解析路径(例如)以找到所有嵌套包。
- pkgs/* - 如果检测到多个包,询问用户要发布哪个包。
1. GitHub Actions Verification
1. GitHub Actions验证
1.1 Configuration Check & Tag Format Discovery
1.1 配置检查与标签格式识别
Run to find and parse publishing workflows.
scripts/inspect_workflows.py [package_name]- The script returns a JSON list of identified workflows, their field, and their
uses.on.push.tags - If a package name is provided, the script ranks workflows based on relevance (e.g., if the filename contains the package name).
- Selection Logic:
- Verify that the chosen workflow's points to
uses.dart-lang/setup-dart/.github/workflows/publish.yml - Extract the expected tag format from the list (e.g.,
tags).v* - If multiple workflows exist, recommend the one with the highest score and ask the user to confirm.
- If the user skips or provides no alternative, proceed with the recommended workflow.
- If no matching workflow is found, show the Github Action Template and guide the user to create one.
- For more details on the automated publishing flow, refer to Automated publishing.
- Verify that the chosen workflow's
运行来查找并解析发布工作流。
scripts/inspect_workflows.py [package_name]- 该脚本会返回已识别工作流的JSON列表,包括它们的字段和
uses配置。on.push.tags - 如果提供了包名称,脚本会根据相关性对工作流进行排序(例如,文件名包含包名称的会优先)。
- 选择逻辑:
- 验证所选工作流的是否指向
uses。dart-lang/setup-dart/.github/workflows/publish.yml - 从列表中提取预期的标签格式(例如
tags)。v* - 如果存在多个工作流,推荐得分最高的工作流并请用户确认。
- 如果用户跳过或未提供替代选项,则使用推荐的工作流继续。
- 如果未找到匹配的工作流,展示Github Action模板并引导用户创建一个。
- 有关自动化发布流程的更多详细信息,请参考自动化发布。
- 验证所选工作流的
2. Versioning Strategy (SemVer)
2. 版本策略(SemVer)
- Use to analyze git history since the last tag.
scripts/prepare_release.py <current_version> [--tag-match <pattern>]- If the tag format from Step 1.2 is non-standard (e.g., ), pass it as
package-name-*to ensure the correct last tag is identified.--tag-match
- If the tag format from Step 1.2 is non-standard (e.g.,
- This script provides a suggested version based on commit types (feat/fix/breaking) and generates a formatted entry.
CHANGELOG.md - Present the suggestion and the draft changelog entry to the user. If the user skips or provides no alternative, proceed with the suggested values.
- Allow the user to edit the version or the content before proceeding.
- 使用分析从上一个标签以来的Git历史。
scripts/prepare_release.py <current_version> [--tag-match <pattern>]- 如果步骤1.2中获取的标签格式是非标准的(例如),将其作为
package-name-*参数传入,以确保识别正确的上一个标签。--tag-match
- 如果步骤1.2中获取的标签格式是非标准的(例如
- 该脚本会根据提交类型(feat/fix/breaking)提供建议版本,并生成格式化的条目。
CHANGELOG.md - 向用户展示建议版本和草稿变更日志条目。如果用户跳过或未提供替代选项,则使用建议的值继续。
- 允许用户在继续前编辑版本或内容。
3. Documentation Updates
3. 文档更新
3.1 pubspec.yaml
3.1 pubspec.yaml
Update the field in the relevant package's with the chosen version.
versionpubspec.yaml将选定的版本更新到对应包的文件的字段中。
pubspec.yamlversion3.2 CHANGELOG.md
3.2 CHANGELOG.md
Insert the confirmed entry at the top of the file (after any initial headers).
Format requirement:
CHANGELOG.mdmarkdown
undefined将确认后的条目插入到文件顶部(在任何初始标题之后)。
格式要求:
CHANGELOG.mdmarkdown
undefined<Version> <YYYY-MM-DD>
<Version> <YYYY-MM-DD>
- feat/fix/... [important] <content>
Note: Ensure the format matches the user's project-specific conventions if they differ from the suggested draft.- feat/fix/... [important] <content>
注意:如果用户项目有特定的格式约定,请确保格式与之一致,而非仅使用建议的草稿格式。4. Git Tagging
4. Git打标签
Add a new git tag matching the format found in Step 1.2 using .
git tag- Example: If the tag format is , the tag should be
v[0-9]+.[0-9]+.[0-9]+.v<version> - Use the exact tag format detected from the workflow file.
使用命令添加一个符合步骤1.2中找到的格式的新Git标签。
git tag- 示例:如果标签格式为,则标签应为
v[0-9]+.[0-9]+.[0-9]+。v<version> - 必须使用从工作流文件中检测到的精确标签格式。
5. Validation
5. 验证
Run to verify the package contents and configuration.
dart pub publish --dry-run- Troubleshooting: If publication consistently fails or you encounter unexpected issues, refer to the official publishing guide for the latest release process and requirements.
运行来验证包的内容和配置。
dart pub publish --dry-run- 故障排除:如果发布持续失败或遇到意外问题,请参考官方发布指南获取最新的发布流程和要求。
Resources
资源
scripts/
scripts/
- : Automatically discovers and parses GitHub Action workflows to identify publishing configurations and tag formats.
inspect_workflows.py- Arguments:
[package_name]
- Arguments:
- : Analyze git history to suggest SemVer version and generate
prepare_release.pyentry.CHANGELOG.md- Arguments:
<current_version> - Optional: (e.g.,
--tag-match <pattern>ormy-pkg-*) to find the correct previous tag.v*
- Arguments:
- :自动发现并解析GitHub Action工作流,以识别发布配置和标签格式。
inspect_workflows.py- 参数:
[package_name]
- 参数:
- :分析Git历史以建议SemVer版本,并生成
prepare_release.py条目。CHANGELOG.md- 参数:
<current_version> - 可选参数:(例如
--tag-match <pattern>或my-pkg-*),用于找到正确的上一个标签。v*
- 参数:
references/
references/
- : A template for setting up the GitHub Action for publishing.
github_action_template.md
- :用于设置发布用GitHub Action的模板。
github_action_template.md