|
1 | | -# This is a basic workflow to help you get started with Actions |
2 | | - |
3 | 1 | name: Publish to Pub.dev |
4 | 2 |
|
5 | | -# Controls when the workflow will run |
6 | 3 | on: |
7 | | - ## Triggers the workflow on push or pull request events but only for the main branch |
8 | | - #push: |
9 | | - # branches: [ main ] |
10 | | - #pull_request: |
11 | | - # branches: [ main ] |
12 | | - |
13 | | - # Allows you to run this workflow manually from the Actions tab |
14 | | - workflow_dispatch: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + # must align with the tag-pattern configured on pub.dev |
| 7 | + # tag-pattern on pub.dev: 'v{{version}}' |
| 8 | + # where {{version}} is identical to what we have in pubspec.yaml |
| 9 | + - "v[0-9]+.[0-9]+.[0-9]+" |
15 | 10 |
|
16 | | -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
17 | 11 | jobs: |
18 | 12 | publishing: |
19 | | - # The type of runner that the job will run on |
20 | 13 | runs-on: ubuntu-latest |
21 | 14 |
|
22 | | - # Steps represent a sequence of tasks that will be executed as part of the job |
| 15 | + permissions: |
| 16 | + id-token: write # Required for authentication using OIDC |
| 17 | + |
| 18 | + environment: pub.dev |
| 19 | + |
23 | 20 | steps: |
24 | | - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
25 | | - - name: 'Checkout' |
26 | | - uses: actions/checkout@v2 # required! |
| 21 | + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 |
27 | 22 |
|
28 | | - - name: 'Update version string' |
| 23 | + - name: Setup Dart SDK and provision OIDC token |
| 24 | + uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c #v1.7.1 |
| 25 | + |
| 26 | + - name: Setup Flutter SDK - needed for publishing Flutter packages. |
| 27 | + uses: flutter-actions/setup-flutter@6d11b83d56c388d0b6fe865194248a01a48548b5 #v4.1 |
| 28 | + |
| 29 | + - name: Update version string |
29 | 30 | run: yq '.version' pubspec.yaml > lib/assets/version.txt |
30 | 31 |
|
31 | | - - name: '>> Dart package <<' |
32 | | - uses: k-paxian/dart-package-publisher@master |
33 | | - with: |
34 | | - accessToken: ${{ secrets.OAUTH_ACCESS_TOKEN }} |
35 | | - refreshToken: ${{ secrets.OAUTH_REFRESH_TOKEN }} |
36 | | - flutter: true |
| 32 | + - name: Install dependencies |
| 33 | + run: dart pub get |
| 34 | + |
| 35 | + - name: Publish (Dry run) |
| 36 | + run: dart pub publish --dry-run |
37 | 37 |
|
| 38 | + # If the package has errors, it won't upload. |
| 39 | + - name: Publish |
| 40 | + run: dart pub publish --force |
0 commit comments