Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable workflow for publishing flutter packages #139

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/flutter_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish flutter to pub.dev

## Caller of this workflow should use it as follows:
## jobs:
## publish:
## uses: dart-lang/setup-dart/.github/workflows/flutter_publish.yml@main [or a recent commit hash / version tag]
## # with:
## # working-directory: path/to/sub/directory

on:
workflow_call:
inputs:
environment:
description: if specified, the workflow is required to be run in this environment (with additional approvals)
required: false
type: string
working-directory:
description: directory with-in the repository where the package is located (if not in the repository root)
required: false
type: string
build_runner:
description: if specified, the workflow will run an additional step of build_runner
required: false
type: boolean

jobs:
flutter_publish:
name: 'Publish to pub.dev'
environment: ${{ inputs.environment }}
permissions:
id-token: write # This is required for requesting the JWT
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Java JDK
uses: actions/[email protected]
with:
distribution: temurin
java-version: "17"
- name: Flutter action
uses: subosito/[email protected]
with:
channel: stable
- name: Flutter version
run: flutter --version
- name: Install dependencies
run: flutter pub get
working-directory: ${{ inputs.working-directory }}
- name: Run build_runner
if: ${{ inputs.build_runner == 'true' }}
run: flutter run build_runner build
working-directory: ${{ inputs.working-directory }}
- name: Publish - dry run
run: flutter pub publish --dry-run
working-directory: ${{ inputs.working-directory }}
# Publishing...
- name: Publish to pub.dev
run: flutter pub publish -f
working-directory: ${{ inputs.working-directory }}
8 changes: 8 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ on:
description: directory with-in the repository where the package is located (if not in the repository root)
required: false
type: string
build_runner:
description: if specified, the workflow will run an additional step of build_runner
required: false
type: boolean

jobs:
publish:
Expand All @@ -35,6 +39,10 @@ jobs:
- name: Install dependencies
run: dart pub get
working-directory: ${{ inputs.working-directory }}
- name: Run build_runner
if: ${{ inputs.build_runner == 'true' }}
run: dart run build_runner build
working-directory: ${{ inputs.working-directory }}
- name: Publish - dry run
run: dart pub publish --dry-run
working-directory: ${{ inputs.working-directory }}
Expand Down