Skip to content

fix: update workflow #4

fix: update workflow

fix: update workflow #4

# .github/workflows/tagpr.yml
name: tagpr and publish
on:
push:
branches: ["main"]
jobs:
tagpr-and-publish:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for authentication using OIDC
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: tagpr
uses: Songmu/tagpr@v1
id: tagpr
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Skip remaining steps if new tag is created
if: steps.tagpr.outputs.tag != ''
continue-on-error: true
run: echo "New tag created. Skipping remaining steps."
- name: Update pubspec.yaml
run: |
yq eval '.version = "${{ steps.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 ${{ steps.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
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: ${{ env.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