Skip to content

Commit 1b460c8

Browse files
committed
add automated publishing
1 parent c5600a0 commit 1b460c8

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish Flutter package to pub.dev
2+
description: Publish your Flutter package to pub.dev
3+
4+
inputs:
5+
working-directory:
6+
description: directory with-in the repository where the package is located (if not in the repository root)
7+
required: false
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: 📚 Git Checkout
13+
uses: actions/checkout@v4
14+
- name: 🐦 Setup Flutter
15+
uses: subosito/flutter-action@v2
16+
17+
- name: 🪪 Get Id Token
18+
uses: actions/github-script@v6
19+
with:
20+
script: |
21+
let pub_token = await core.getIDToken('https://pub.dev')
22+
core.exportVariable('PUB_TOKEN', pub_token)
23+
24+
- name: 📢 Authenticate
25+
shell: ${{ inputs.shell }}
26+
run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN
27+
28+
- name: 📦 Install dependencies
29+
shell: ${{ inputs.shell }}
30+
run: flutter pub get
31+
working-directory: ${{ inputs.working-directory }}
32+
33+
# - name: 🌵 Dry Run
34+
# shell: ${{ inputs.shell }}
35+
# run: flutter pub publish --dry-run
36+
# working-directory: ${{ inputs.working-directory }}
37+
38+
- name: 📢 Publish
39+
shell: ${{ inputs.shell }}
40+
run: flutter pub publish -f
41+
working-directory: ${{ inputs.working-directory }}

.github/workflows/publish.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Publish to pub.dev
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+*'
7+
8+
jobs:
9+
publish:
10+
environment: 'pub.dev'
11+
permissions:
12+
id-token: write # Required for authentication using OIDC
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: 📚 Git Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
submodules: recursive
19+
- uses: ./.github/actions/publish_flutter_package

0 commit comments

Comments
 (0)