Skip to main content

Dart Pub Publish

We use this workflow to publish a Dart package to pub.dev.

Steps​

The Dart Pub Publish workflow consists of the following steps:

  1. Setup Dart, including pub.dev publish token
  2. Install dependencies
  3. Dry run
  4. Publish

This workflow uses the automated publishing of packages to pub.dev which is part of the Dart documentation. Before using this workflow ensure that you have configured your package on pub.dev correctly to allow the publish process to complete.

Because this is a reusable workflow, it cannot grant itself the permissions required for OIDC publishing. The calling job must grant id-token: write so that dart-lang/setup-dart can request the OIDC token used to authenticate with pub.dev:

permissions:
id-token: write

Inputs​

dart_sdk​

Optional The Dart SDK version to install with the Setup Dart action before publishing. Use a version, such as 3.5.0, or a channel, such as stable.

Default "stable"

working_directory​

Optional The path to the root of the Dart package.

Default "."

runs_on​

Optional An optional operating system on which to run the workflow.

Default "ubuntu-latest"

timeout_minutes​

Optional The maximum number of minutes the publish job is allowed to run before it is cancelled.

Default 5

environment​

Optional The GitHub deployment environment to run the publish job in. Leave empty to run without a deployment environment.

Default ""

Example Usage​

name: My Dart Pub Publish Workflow

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'

jobs:
publish:
permissions:
id-token: write
uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/dart_pub_publish.yml@v2
with:
dart_sdk: 'stable'
working_directory: 'packages/my_dart_package'