Flutter › Publishing Packages on pub.dev
How can you properly set up an automated CI/CD pipeline specifically to automatically test, version, and publish a given package to pub.dev whenever a genuinely new release is actually properly ready?
AdvancedAnswer
Automating a package's own entire publishing workflow typically involves configuring a CI pipeline that automatically runs the package's own complete test suite and its static analysis checks on every single pull request, and then, once a genuinely new release is properly ready, automatically running dart pub publish whenever a genuinely new corresponding version tag is actually pushed to the repository, and properly configuring pub.dev's own dedicated automated publishing feature, which relies on a secure trusted connection with your own specific CI provider rather than requiring you to manually and repeatedly enter your own personal publishing credentials by hand every single time.
# GitHub Actions workflow triggered by a version tag, automatically publishing to pub.dev
on:
push:
tags:
- 'v*'
jobs:
publish:
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1Real-world example A package maintainer sets up an automated GitHub Actions workflow that automatically publishes a genuinely new version to pub.dev the instant they push a corresponding new version tag, meaningfully streamlining what used to be a genuinely manual, error prone multi step publishing process into just one single simple git command.