.github/workflows/publish.yml
# https://dart.dev/tools/pub/automated-publishing#hardening-security-with-tag-protection-rules-on-github
name: Publish to pub.dev
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+' # tag pattern on pub.dev: 'v{{version}'
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Analyze
run: dart analyze
- name: Format
run: dart format --set-exit-if-changed .
- name: Dry run
run: flutter pub publish --dry-run
test:
needs: analyze
uses: ./.github/workflows/ci.yml
with:
run_all: true
publish:
environment: pub.dev
needs: test
permissions:
id-token: write # Required for authentication using OIDC
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- name: Install dependencies
run: flutter pub get
- uses: dart-lang/setup-dart@v1
- name: Publish
run: dart pub publish --force