blob: 8b39fea7c9b4ad3ba923eb0d00d315a5c7daae1d [file] [log] [blame]
# A CI configuration to auto-publish pub packages.
name: Publish
# Callers of this workflow should use it as follows:
#
# name: Publish
# on:
# pull_request:
# branches: [ main ]
# types: [opened, synchronize, reopened, labeled, unlabeled]
# push:
# tags: [ 'v[0-9]+.[0-9]+.[0-9]+' ]
# jobs:
# publish:
# uses: dart-lang/ecosystem/.github/workflows/publish.yml@main
# Callers may optionally specify the version of the SDK to use when publishing a
# package. This can be useful if your package has a very recent minimum SDK
# constraint. This is done via the `sdk` input parameter. Note that this
# parameter is not required; it defaults to `stable` - using the most recent
# stable release of the Dart SDK. To pass this value:
#
# jobs:
# publish:
# uses: dart-lang/ecosystem/.github/workflows/publish.yml@main
# with:
# sdk: beta
# When using this package to publish Flutter packages, the `use_flutter`
# parameter should be set. The `sdk` parameter is then used to specify
# the Flutter SDK.
#
# jobs:
# publish:
# uses: dart-lang/ecosystem/.github/workflows/publish.yml@main
# with:
# use_flutter: true
on:
workflow_call:
inputs:
environment:
description: >-
If specified, publishes will be performed from this environment,
which will require additional approvals. See
https://dart.dev/tools/pub/automated-publishing for more
information.
required: false
type: string
sdk:
description: >-
The channel, or a specific version from a channel, to install
('2.19.0','stable', 'beta', 'dev'). Using one of the three channels
will give you the latest version published to that channel.
default: "stable"
required: false
type: string
use_flutter:
description: >-
Whether to setup Flutter in this workflow.
default: false
required: false
type: boolean
jobs:
# Note that this job does not require the specified environment.
validate:
if: ${{ github.event_name == 'pull_request' }}
# These permissions are required for authentication using OIDC and to enable
# us to create comments on PRs.
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: ${{ inputs.sdk }}
- name: Install firehose
run: dart pub global activate firehose
- name: Validate packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.number }}
PR_LABELS: "${{ join(github.event.pull_request.labels.*.name) }}"
run: dart pub global run firehose --validate
publish:
if: ${{ github.event_name == 'push' }}
# Require the github deployment environment if supplied.
environment: ${{ inputs.environment }}
# This permission is required for authentication using OIDC.
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- uses: subosito/flutter-action@48cafc24713cca54bbe03cdc3a423187d413aafa
if: ${{ inputs.use_flutter }}
with:
channel: ${{ inputs.sdk }}
- uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
if: ${{ !inputs.use_flutter }}
with:
sdk: ${{ inputs.sdk }}
- name: Install firehose
run: dart pub global activate firehose
- name: Publish packages
run: dart pub global run firehose --publish