Skip to content

Commit

Permalink
add automated publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed Nov 5, 2024
1 parent c52bf8e commit 27d64bc
Showing 1 changed file with 37 additions and 17 deletions.
54 changes: 37 additions & 17 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
name: Publish to pub.dev
name: Publish Flutter package to pub.dev
description: Publish your Flutter package to pub.dev

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
inputs:
working-directory:
description: directory with-in the repository where the package is located (if not in the repository root)
required: false

jobs:
runs:
using: "composite"
steps:
- name: Install Flutter
run: |
git clone https://github.com/flutter/flutter.git -b stable --depth 1
export PATH="$PATH:`pwd`/flutter/bin"
flutter doctor
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2

publish:
permissions:
id-token: write # Required for authentication using OIDC
uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1
# with:
# working-directory: path/to/package/within/repository
- name: 🪪 Get Id Token
uses: actions/github-script@v6
with:
script: |
let pub_token = await core.getIDToken('https://pub.dev')
core.exportVariable('PUB_TOKEN', pub_token)
- name: 📢 Authenticate
shell: ${{ inputs.shell }}
run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN

- name: 📦 Install dependencies
shell: ${{ inputs.shell }}
run: flutter pub get
working-directory: ${{ inputs.working-directory }}

- name: 🌵 Dry Run
shell: ${{ inputs.shell }}
run: flutter pub publish --dry-run
working-directory: ${{ inputs.working-directory }}

- name: 📢 Publish
shell: ${{ inputs.shell }}
run: flutter pub publish -f
working-directory: ${{ inputs.working-directory }}

0 comments on commit 27d64bc

Please sign in to comment.