Skip to content

Commit 85e5a85

Browse files
authored
feat: update publish workflows to use Setup Dart action (#272)
* feat: update publish workflows to use Setup Dart action * update docs
1 parent 4f1a9e8 commit 85e5a85

File tree

4 files changed

+20
-44
lines changed

4 files changed

+20
-44
lines changed

.github/workflows/dart_pub_publish.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ on:
1515
required: false
1616
type: string
1717
default: "ubuntu-latest"
18-
# Deprecated, use secrets.pub_credentials instead
19-
pub_credentials:
20-
required: false
21-
type: string
2218
timeout_minutes:
2319
required: false
2420
type: number
2521
default: 5
22+
# Deprecated, will be used if passed in but using the "Setup Dart" action is recommended
2623
secrets:
2724
pub_credentials:
2825
required: true
@@ -36,7 +33,7 @@ jobs:
3633
runs-on: ${{inputs.runs_on}}
3734

3835
timeout-minutes: ${{inputs.timeout_minutes}}
39-
36+
4037
steps:
4138
- name: 📚 Git Checkout
4239
uses: actions/checkout@v4
@@ -50,6 +47,7 @@ jobs:
5047
run: dart pub get
5148

5249
- name: 🔐 Setup Pub Credentials
50+
if: ${{ secrets.pub_credentials != '' }}
5351
run: |
5452
mkdir -p $XDG_CONFIG_HOME/dart
5553
echo '${{secrets.pub_credentials}}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"

.github/workflows/flutter_pub_publish.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ on:
1919
required: false
2020
type: string
2121
default: "ubuntu-latest"
22-
# Deprecated, use secrets.pub_credentials instead
23-
pub_credentials:
24-
required: false
25-
type: string
2622
timeout_minutes:
2723
required: false
2824
type: number
2925
default: 5
26+
# Deprecated, will be used if passed in but using the "Setup Dart" action is recommended
3027
secrets:
3128
pub_credentials:
3229
required: true
@@ -40,7 +37,7 @@ jobs:
4037
runs-on: ${{inputs.runs_on}}
4138

4239
timeout-minutes: ${{inputs.timeout_minutes}}
43-
40+
4441
steps:
4542
- name: 📚 Git Checkout
4643
uses: actions/checkout@v4
@@ -55,11 +52,18 @@ jobs:
5552
- name: 📦 Install Dependencies
5653
run: flutter pub get
5754

58-
- name: 🔐 Setup Pub Credentials
55+
- name: 🔐 Setup Pub Credentials\
56+
if: ${{ secrets.pub_credentials != '' }}
5957
run: |
6058
mkdir -p $XDG_CONFIG_HOME/dart
6159
echo '${{secrets.pub_credentials}}' > "$XDG_CONFIG_HOME/dart/pub-credentials.json"
6260
61+
- name: 🎯 Setup Dart
62+
if: ${{ secrets.pub_credentials == '' }}
63+
uses: dart-lang/setup-dart@v1
64+
with:
65+
sdk: ${{inputs.dart_sdk}}
66+
6367
- name: 🌵 Dry Run
6468
run: flutter pub publish --dry-run
6569

site/docs/workflows/dart_pub_publish.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ We use this workflow to publish a Dart package to [pub.dev](https://pub.dev).
1010

1111
The Dart Pub Publish workflow consists of the following steps:
1212

13-
1. Install dependencies
14-
2. Setup pub credentials
13+
1. Setup Dart, including pub.dev publish token
14+
2. Install dependencies
1515
3. Dry run
1616
4. Publish
1717

18+
This workflow uses the automated publishing of packages to pub.dev which is part of the [Dart documentation](https://dart.dev/tools/pub/automated-publishing). Before using this workflow ensure that you have configured your package on pub.dev correctly to allow the publish process to complete.
19+
1820
## Inputs
1921

2022
### `dart_sdk`
@@ -35,22 +37,8 @@ The Dart Pub Publish workflow consists of the following steps:
3537

3638
**Default** `"ubuntu-latest"`
3739

38-
## Secrets
39-
40-
### `pub_credentials`
41-
42-
**Required** The pub credentials needed for publishing. This can be retrieved by reading out your `pub-credentials.json` on your system after you ran a `dart pub login`, the location of the file is different per operating system:
43-
44-
| OS | Path |
45-
| ------- | ----------------------------------------------------------------------------------------- |
46-
| Linux | `$XDG_CONFIG_HOME/dart/pub-credentials.json` or `$HOME/.config/dart/pub-credentials.json` |
47-
| macOS | `~/Library/Application\ Support/dart/pub-credentials.json` |
48-
| Windows | `%APPDATA%/dart/pub-credentials.json` |
49-
5040
## Example Usage
5141

52-
We recommend using [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) for safely storing and reading the credentials.
53-
5442
```yaml
5543
name: My Dart Pub Publish Workflow
5644

@@ -62,6 +50,4 @@ jobs:
6250
with:
6351
dart_sdk: 'stable'
6452
working_directory: 'packages/my_dart_package'
65-
secrets:
66-
pub_credentials: secrets.PUB_CREDENTIALS
6753
```

site/docs/workflows/flutter_pub_publish.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ We use this workflow to publish a Flutter package to [pub.dev](https://pub.dev).
1111
The Flutter Pub Publish workflow consists of the following steps:
1212

1313
1. Install dependencies
14-
2. Setup pub credentials
14+
2. Setup Flutter & Dart, including pub.dev publish token
1515
3. Dry run
1616
4. Publish
1717

18+
This workflow uses the automated publishing of packages to pub.dev which is part of the [Dart documentation](https://dart.dev/tools/pub/automated-publishing). Before using this workflow ensure that you have configured your package on pub.dev correctly to allow the publish process to complete.
19+
1820
## Inputs
1921

2022
### `flutter_channel`
@@ -41,18 +43,6 @@ The Flutter Pub Publish workflow consists of the following steps:
4143

4244
**Default** `"ubuntu-latest"`
4345

44-
## Secrets
45-
46-
### `pub_credentials`
47-
48-
**Required** The pub credentials needed for publishing. This can be retrieved by reading out your `pub-credentials.json` on your system after you ran a `flutter pub login`. The location of the file is different per operating system:
49-
50-
| OS | Path |
51-
| ------- | ----------------------------------------------------------------------------------------- |
52-
| Linux | `$XDG_CONFIG_HOME/dart/pub-credentials.json` or `$HOME/.config/dart/pub-credentials.json` |
53-
| macOS | `~/Library/Application\ Support/dart/pub-credentials.json` |
54-
| Windows | `%APPDATA%/dart/pub-credentials.json` |
55-
5646
## Example Usage
5747

5848
We recommend using [GitHub Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) for safely storing and reading the credentials.
@@ -72,6 +62,4 @@ jobs:
7262
flutter_channel: 'stable'
7363
flutter_version: '3.24.0'
7464
working_directory: 'packages/my_flutter_package'
75-
secrets:
76-
pub_credentials: secrets.PUB_CREDENTIALS
7765
```

0 commit comments

Comments
 (0)