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 32bbf9e commit aaf1bb9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
41 changes: 41 additions & 0 deletions .github/actions/publish_flutter_package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish Flutter package to pub.dev
description: Publish your Flutter package to pub.dev

inputs:
working-directory:
description: directory with-in the repository where the package is located (if not in the repository root)
required: false

runs:
using: "composite"
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v4
- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2

- 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 }}
14 changes: 7 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:

jobs:
publish:
environment: 'pub.dev'
permissions:
id-token: write # Required for authentication using OIDC
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Publish
uses: k-paxian/dart-package-publisher@master
- name: 📚 Git Checkout
uses: actions/checkout@v4
with:
credentialJson: ${{ secrets.CREDENTIAL_JSON }}
flutter: true
skipTests: true
submodules: recursive
- uses: ./.github/actions/publish_flutter_package

0 comments on commit aaf1bb9

Please sign in to comment.