Dart 包版本发布
release-dart-package
准备并将 Dart 包的新版本发布到 pub.dev,涵盖从版本号提升到 GitHub release 的完整流程。当被要求创建(cut)、打标签(tag)或发布(publish)版本时使用。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 8
- Forks
- 7
01 前言 Front Matter
- name
- release-dart-package
- license
- Apache-2.0
- metadata
- { "internal": true }
- description
- Prepares and publishes a new version of a Dart package to pub.dev, from the version bump to the GitHub release. Use when asked to cut, tag or publish a release.
- allowed-tools
- Bash Read Write
- compatibility
- Needs the Dart SDK, git and the GitHub CLI, with publish rights on pub.dev.
02 资源文件 5
- 参考文档references/changelog-guide.md1.1 KB
- 参考文档references/checklist.md1.1 KB
- 参考文档references/versioning.md1.1 KB
- 脚本scripts/check-version.sh583 B
- 脚本scripts/publish-dry-run.sh302 B
03 SKILL.md 正文
Release a Dart package
Use this skill to publish a new version of a package to pub.dev. A release has four parts: choose the version, update the changelog, publish, and tag. Do them in that order, and stop at the first problem.
Read checklist.md before you start. It is the short version of this skill, for when you have done a release before.
Choose the version
The package follows semantic versioning. Read versioning.md for the details. In short:
- A breaking change to the public API, the CLI flags, or the config file format needs a major version, or a minor version while the package is below 1.0.0.
- A new feature that doesn't break anything needs a minor version, or a patch version below 1.0.0.
- A fix that doesn't change the API needs a patch version.
When you're not sure whether a change breaks users, treat it as breaking.
git log --oneline "v$(scripts/check-version.sh --current)..HEAD"
Read every commit since the last tag. Sort them into breaking changes, new features and fixes. That list becomes the changelog entry.
Update the changelog
- Open
CHANGELOG.md. The top section is usually namedX.Y.Z-wip. - Rename it to the version you chose. Remove
-wip. - Check each entry against changelog-guide.md: entries are for users, start with a verb, and name the flag or API.
- Move entries that no user would notice out of the changelog.
- Set the same version in
pubspec.yaml.
Run the version check. It fails if pubspec.yaml, CHANGELOG.md and the
version constant in the code don't agree.
scripts/check-version.sh
Run the checks
Run every check that CI runs, from a clean checkout of the release commit:
dart pub get
dart format --output=none --set-exit-if-changed .
dart analyze --fatal-infos
dart test
Then do a dry run of the publish. It lists every file that will be uploaded. Look for files that shouldn't be there, such as local config, build output or large test data.
scripts/publish-dry-run.sh
If the dry run warns about anything, fix it before you publish. A version on pub.dev can't be changed or deleted, only retracted.
Publish
- Send the version bump and changelog as a pull request, and wait for review and green CI.
- Merge it.
- From the merge commit on
main, rundart pub publish. - Check the package page on pub.dev. The new version, the changelog and the score can take a few minutes to show.
Tag and release
Tag the merge commit, and push the tag:
version="$(scripts/check-version.sh --current)"
git tag -a "v$version" -m "v$version"
git push origin "v$version"
gh release create "v$version" --title "v$version" --notes-from-tag
Paste the changelog section into the release notes.
After the release
- Add a new
X.Y.Z-wipsection at the top of the changelog, with the next patch version, and a matching version inpubspec.yaml. - Tell the downstream repositories that use the package that a new version is out, and link to the changelog.
- If something went wrong, write it down in the checklist so the next release avoids it.
If something goes wrong
- The publish failed. Read the error, fix it on a new branch, and start again from "Run the checks". The version wasn't used, so you can keep it.
- The published version is broken. Retract it on pub.dev, fix the problem, and release a new patch version. Don't reuse the version number.
- The tag points at the wrong commit. Delete the tag locally and on GitHub, then tag the right commit. Do this only before anyone has used the tag.
04 同仓库更多 Skills
Dart 单元测试基础
dart-test-fundamentals
`package:test` 的核心概念与最佳实践。 涵盖 `test`、`group`、生命周期方法(`setUp`、`tearDown`)以及配置(`dart_test.yaml`)。
Dart 断言匹配器最佳实践
dart-matcher-best-practices
使用 `expect` 和 `package:matcher` 的最佳实践。 重点关注可读的断言、正确选择匹配器以及避免常见陷阱。
Dart 长行代码规范处理
dart-long-lines
处理 Dart 代码中长行以遵守 80 列规则的指南,即 `lines_longer_than_80_chars` lint 检查。
Dart 文档注释校验
dart-doc-validation
验证 Dart 文档注释的最佳实践。涵盖使用 `dart doc` 检测未解析的引用和宏。
Dart 开发最佳实践
dart-best-practices
Dart 开发的通用最佳实践。涵盖代码风格、Effective Dart(有效的 Dart)和语言特性。
GitHub Issue 分类与整理
triage-github-issues
按类型和优先级对新的 GitHub issue 进行分类,询问缺失的详细信息,并关闭重复项。当被要求对 issue tracker 进行分类(triage)、添加标签或清理时使用。