Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
package

GitHub Action

Dart and Flutter Package Publisher

v1.0

Dart and Flutter Package Publisher

package

Dart and Flutter Package Publisher

Continuously Test & Publish Dart and Flutter Package To Pub.dev When Version Changed

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Dart and Flutter Package Publisher

uses: k-paxian/[email protected]

Learn more about this action in k-paxian/dart-package-publisher

Choose a version

Build Status

The Challenge

Usually, when you are trying to pub lish your package and your pubspec.yaml has the same version as already published, you'll have a non zero exit code from pub tool. So you cannot directly put this command as an re-action on: push event.

This Action is intended to solve this challenge by continuously Test & Publish Dart 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, pull_request events.

on: [push, pull_request]

and forget about it. When you need to publish a package, just bump the version in pubspec.yaml.

Inputs

accessToken

Required Google Account token from ~/.pub-cache/credentials.json Put it as secrets.OAUTH_ACCESS_TOKEN on your repo secrets section

You can find the credentials.json within .pub-cache in the User's home directory. You can use open ~/.pub-cache.

refreshToken

Required Google Account token from ~/.pub-cache/credentials.json Put it as secrets.OAUTH_REFRESH_TOKEN on your repo secrets section

You can find the credentials.json within .pub-cache in the User's home directory. You can use open ~/.pub-cache.

relativePath

Optional Path to your package root in your repository. In case you have a mono-repo, like this one

flutter

Optional Declares a package as a Flutter package. Default: false

dryRunOnly

Optional Perform dry run only, no real publishing. Default: false

skipTests

Optional Skip unit tests run. Default: false

suppressBuildRunner

Optional Suppress using build_runner for unit tests run. Default: false

Outputs

package

Package name from pubspec

localVersion

Package local version from pubspec

remoteVersion

Package remote version from pub.dev

dartVersion

Dart SDK version which is being used to run tests & publish

flutterVersion

Flutter SDK version which is being used to run tests & publish

Dart package example usage

name: Publish to Pub.dev

on: push

jobs:
  publishing:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: actions/checkout@v2 # required!
        
      - name: '>> Dart package <<'
        uses: k-paxian/dart-package-publisher@master
        with:
          accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }}
          refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }}

Flutter package example usage

name: Publish to Pub.dev

on: push

jobs:
  publishing:
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout'
        uses: actions/checkout@v2 # required!

      - name: '>> Flutter package <<'
        uses: k-paxian/dart-package-publisher@master
        with:
          accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }}
          refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }}
          flutter: true