Skip to content

Commit

Permalink
ci: Update publish action (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
witwash authored Aug 5, 2024
1 parent cf5dc50 commit 07a2ceb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 27 deletions.
44 changes: 44 additions & 0 deletions .github/actions/publish/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish Flutter package to pub.dev
description: Publish your Flutter package to pub.dev

inputs:
working-directory:
description: A directory with package to publish
required: true

runs:
using: "composite"
steps:
- name: Git Checkout
uses: actions/checkout@v4

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: 3.22.3

- 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: bash
run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN

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

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

- name: Publish
shell: bash
run: flutter pub publish -f
working-directory: ${{ inputs.working-directory }}
16 changes: 2 additions & 14 deletions .github/workflows/mews_pedantic-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,12 @@ jobs:
name: Publish to pub.dev
runs-on: ubuntu-latest
environment: pub.dev

permissions:
id-token: write

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Flutter
uses: subosito/flutter-action@v2
- uses: ./.github/actions/publish
with:
flutter-version: 3.22.2

- name: Install dependencies
run: flutter pub get

- name: Publish Dry Run
run: flutter pub publish --directory=mews_pedantic --dry-run

- name: Publish to pub.dev
run: flutter pub publish --directory=mews_pedantic --force
working-directory: mews_pedantic
15 changes: 2 additions & 13 deletions .github/workflows/optimus-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,10 @@ jobs:
environment: pub.dev
permissions:
id-token: write

steps:
- name: Clone repository
uses: actions/checkout@v4

- name: Install Flutter
uses: subosito/flutter-action@v2
- uses: ./.github/actions/publish
with:
flutter-version: 3.22.2

- name: Install dependencies
run: flutter pub get

- name: Publish Dry Run
run: flutter pub publish --directory=optimus --dry-run

- name: Publish to pub.dev
run: flutter pub publish --directory=optimus --force
working-directory: optimus

0 comments on commit 07a2ceb

Please sign in to comment.