Continuously Test & Publish Dart and Flutter Package To Pub.dev When Version Changed
You have to be a Verified Publisher to be able to publish from GH action w/o Pub needs your authorization to upload packages on your behalf
check in console.
Usually, when you are trying to pub lish
your Dart package (or pub publish
your Flutter package) and your pubspec.yaml
has the same version as already published, you'll have a non zero exit code from pub
tool and
your workflow is red 🔴.
So you cannot directly hook publish command as an re-action to on: push
event.
To keep a workflow green 🟢 on each push, you have to prevent publishing step if versions are the same, and to compare versions, you should have both of them, remote and local.
This Action is intended to solve this challenge by continuously Test & Publish Dart/Flutter packages only IF local pubspec.yml
has different version than already published on Pub.dev site.
It's handy to hook it up on push
events.
on: push
and forget about it. When you need to publish a package, just bump the version in pubspec.yaml
.
Finally, after 3 years of silence Google did that job in house 😄 firehose
Required Google Account token from ~/.config/dart/pub-credentials.json
Put it as secrets.OAUTH_ACCESS_TOKEN
on your repo secrets section
You can find the pub-credentials.json within .config/dart
in the User's home directory.
You can use open ~/.config/dart
.
Required Google Account token from ~/.config/dart/pub-credentials.json
Put it as secrets.OAUTH_REFRESH_TOKEN
on your repo secrets section
You can find the pub-credentials.json within .config/dart
in the User's home directory.
You can use open ~/.config/dart
.
Replaces accessToken
and refreshToken
and contains the whole content of the ~/.config/dart/pub-credentials.json
file
Put it as secrets.CREDENTIAL_JSON
on your repo secrets section
You can find the pub-credentials.json
within .config/dart
in the User's home directory.
You can use open ~/.config/dart
after your first publication either through dart pub lish
command for Dart or flutter pub publish
for Flutter.
Optional Path to your package root in your repository. In case you have a mono-repo, like this one
Optional Perform dry run only, no real publishing. Default: false
Optional Perform unit tests run only, no real publishing. Default: false
Optional Skip unit tests run. Default: false
Optional Suppress using build_runner
for unit tests run. Default: false
Optional Format code of project to get better score in pub.dev. Default: false
Optional Force publishing even if pub tool throws warnings, hints, etc. Default: false
Optional Flutter package type. Default: false
, when omitted auto detected
Optional Flutter branch to use, stable, master, main, dev, etc. Default: stable
Result, "true" if actual publishing happened, "false" otherwise
Package name from pubspec
Package local version from pubspec
Package remote version from pub.dev
Dart SDK version which is being used to run tests & publish
Flutter SDK version which is being used to run tests & publish
name: Publish to Pub.dev
on: push
jobs:
publishing:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@main # required!
- name: '>> Dart package <<'
uses: k-paxian/dart-package-publisher@master
with:
accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }}
refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }}