Skip to content
# .github/workflows/tagpr.yml
name: tagpr and publish
on:
push:
branches: ["main"]
jobs:
tagpr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
tag: ${{ steps.tagpr.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: tagpr
uses: Songmu/tagpr@v1
id: tagpr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish:
needs: tagpr
if: ${{ needs.tagpr.outputs.tag != '' }}
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for authentication using OIDC
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update pubspec.yaml
run: |
yq eval '.version = "${{ needs.tagpr.outputs.tag }}"' pubspec.yaml -i
git config user.name github-actions
git config user.email [email protected]
git add pubspec.yaml
git commit -m "Update pubspec.yaml version to ${{ needs.tagpr.outputs.tag }}"
git push
# Publish to pub.dev
# https://github.com/dart-lang/setup-dart/blob/v1/.github/workflows/publish.yml
- name: Fetch flutter config
uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
cache: true
# https://github.com/actions/cache
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
${{ env.PUB_CACHE }}
${{ github.workspace }}/.packages
${{ github.workspace }}/.flutter-plugins
${{ github.workspace }}/.flutter-plugin-dependencies
${{ github.workspace }}/.dart_tool/package_config.json
key: build-pubspec-${{ hashFiles(format('{0}{1}', github.workspace, '/pubspec.lock')) }}
restore-keys: |
build-pubspec-
- name: Install dependencies
run: |
flutter pub get
- name: Publish - dry run
run: dart pub publish --dry-run
# Publishing...
- name: Publish to pub.dev
run: dart pub publish -f