Skip to content

Commit a57a6c0

Browse files
authored
Reusable workflow for publishing. (#64)
* Reusable workflow for publishing.
1 parent 7b1734b commit a57a6c0

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/publish.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish to pub.dev
2+
3+
## Caller of this workflow should use it as follows:
4+
## jobs:
5+
## publish:
6+
## uses: dart-lang/setup-dart/.github/workflows/publish.yml@main [or a recent commit hash / version tag]
7+
## # with:
8+
## # working-directory: path/to/sub/directory
9+
10+
on:
11+
workflow_call:
12+
inputs:
13+
environment:
14+
description: if specified, the workflow is required to be run in this environment (with additional approvals)
15+
required: false
16+
type: string
17+
working-directory:
18+
description: directory with-in the repository where the package is located (if not in the repository root)
19+
required: false
20+
type: string
21+
22+
jobs:
23+
publish:
24+
name: 'Publish to pub.dev'
25+
environment: ${{ inputs.environment }}
26+
permissions:
27+
id-token: write # This is required for requesting the JWT
28+
runs-on: ubuntu-latest
29+
steps:
30+
# Checkout repository
31+
- uses: actions/checkout@v3
32+
# Setup Dart SDK with JWT token
33+
- uses: dart-lang/setup-dart@7b1734b5b08d53fbf347cf96b664fa1a49cc6497
34+
# Minimal package setup and dry run checks.
35+
- name: Install dependencies
36+
run: dart pub get
37+
working-directory: ${{ inputs.working-directory }}
38+
- name: Publish - dry run
39+
run: dart pub publish --dry-run
40+
working-directory: ${{ inputs.working-directory }}
41+
# Publishing...
42+
- name: Publish to pub.dev
43+
run: dart pub publish -f
44+
working-directory: ${{ inputs.working-directory }}

0 commit comments

Comments
 (0)