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

Cannot publish in such env. #7

Closed
aprosail opened this issue May 14, 2024 · 10 comments
Closed

Cannot publish in such env. #7

aprosail opened this issue May 14, 2024 · 10 comments

Comments

@aprosail
Copy link

I've wrote a script based on such Flutter SDK env setup in order to publish a Flutter package onto pub.dev. Publishing from GitHub Actions requires OIDC, but once using this action, even if permissions: {id-token: write} is enabled, it cannot authentic with OIDC and the publishing process can never finish.

Here's my publish.yaml file inside .github/workflows folder:

name: publish

on:
  push:
    tags: ["v[0-9]+.[0-9]+.[0-9]+*"]

jobs:
  # https://dart.dev/tools/pub/automated-publishing
  publish:
    runs-on: ubuntu-latest
    permissions: {id-token: write}
    steps:
      - uses: actions/checkout@v4
      - uses: flutter-actions/setup-flutter@v3
      - run: flutter pub get
      - run: flutter pub publish --dry-run
      - run: flutter pub publish --force
@aprosail
Copy link
Author

I've found a solution, but it's a little bit waste computational resources: add a line to setup Dart environment using the official Dart setup action, and it can publish normally. Just like the following code:

name: publish

on:
  push:
    tags: ["v[0-9]+.[0-9]+.[0-9]+*"]

jobs:
  # https://dart.dev/tools/pub/automated-publishing
  publish:
    runs-on: ubuntu-latest
    permissions: {id-token: write}
    steps:
      - uses: actions/checkout@v4
      - uses: dart-lang/setup-dart@v1
      - uses: flutter-actions/setup-flutter@v3
      - run: flutter pub get
      - run: flutter pub publish --dry-run
      - run: flutter pub publish --force

But this workflow will also setup a Dart environment, which is repeated, as the Flutter SDK includes a Dart SDK. So it's still recommended to fix something about OIDC in this action repo.

@aprosail
Copy link
Author

It's not a problem about version specification. I've tried with specified versions, even older versions, but such problem always appear.

@socheatsok78

This comment was marked as outdated.

@socheatsok78
Copy link
Member

socheatsok78 commented May 14, 2024

I think I found the solution to this, since the official dart-lang/setup-dart implement a createPubOIDCToken method to automate the GitHub OIDC Token, it is possible to add this as well.

https://github.com/dart-lang/setup-dart/blob/2986c8e337a31eb7b455ce93dc984e9bf5797756/lib/main.dart#L162-L186

Not able to guarantee when this will be done, but I will try to add it asap.

@aprosail
Copy link
Author

Thanks, I can understand where the problem is according to the code you mentioned before. If I'm available, I will also try to fix this problem and make a PR.

@socheatsok78
Copy link
Member

Thanks, I can understand where the problem is according to the code you mentioned before. If I'm available, I will also try to fix this problem and make a PR.

I've put sth together for this particular issue. Maybe you can give it a try https://github.com/flutter-actions/setup-pubdev-credentials.

You can temporarily use the main channel for this time being, v1 is still awaited testing.

@aprosail
Copy link
Author

I've put sth together for this particular issue. Maybe you can give it a try https://github.com/flutter-actions/setup-pubdev-credentials.

You can temporarily use the main channel for this time being, v1 is still awaited testing.

Wow, you are so fast. Sorry that I'm really busy these days. I'll try the new action asap once my package's new version is prepared.

@aprosail
Copy link
Author

This new action works well and I have already published my new package using such action successfully. Thanks a lot.

@socheatsok78
Copy link
Member

Glad to hear that 😉

@socheatsok78
Copy link
Member

refs: flutter/flutter#148296, dart-lang/setup-dart#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants