Four steps to publish a package
Prepare an account that can publish the package (recommended use a verified account - 🔗Advantages of using a verified publisher)
A package that meets the criteria for release.(eg. 🔗svg_to_font ).
You can rundart pub publish --dry-run
under the package’s Root path to verify it before publishing and fix the result accordingly.dart pub publish
: The first publish is done interactively on the command line and is mainly used to verify that the user and it will generate the corresponding tokens.Click to show details 👉
Transfer packages that have not been sent to pub.dev from your account to an authenticated account (Details 👉🔗 Publishing packages | Dart).
Click to show svg_to_font 👉
🎉 At this point, you have completed the entire process of manually publishing a package.
Automated publishing via GitHub Actions
Mainly using Dart and Flutter Package Publisher
Add a new file,
.github/workflows/publish.yml
to the root directoryFile content reference svg_to_font
Get
PUB_ACCESS_TOKEN
andPUB_REFRESH_TOKEN
According to Dart and Flutter Package Publisher, it is likely that you will not get them.Click to show Dart and Flutter Package Publisher Doc 👉
Check the source code of dart cli, for example, macOS, the correct address is
~/Library/Application Support/dart/pub-credentials.json
Configure GitHub Actions secrets (Address:
https://github.com/<REPLACE Your Repo>/settings/secrets/actions
)Take this article’s repository as an example, and type a tag that starts with the letter “v” and it will automatically publish