在 CI 中发布 pub.dev 包的最简单方法是什么?
What is the easiest way to publish a pub.dev package in a CI?
我正在尝试使用 dart pub publish
在 Github 操作中自动发布一个包,但为此我需要登录。登录工作流程需要用户交互(通过 Google 登录),因此不能在 CI.
上使用
根据 https://github.com/dart-lang/pub/issues/2227 似乎没有简单的方法,但有人提到:
Having to put the path like run: echo ${{secrets.PUB_CREDENTIALS}} > /opt/hostedtoolcache/flutter/1.9.1-hotfix.2-stable/x64/.pub-cache/credentials.json
is not really great to maintain.
这个 credentials.json
的格式是否已知?
编辑:在 Windows 上,the credentials.json
文件不在 C:\Users\<USER>\AppData\Roaming\Pub\Cache\credentials.json
中,如博客 post 中所述,它现在在 C:\Users\<USER>\AppData\Roaming\dart\pub-credentials.json
.
This medium post has a clear guide that could help you on publishing Flutter or Dart packages to pub.dev 通过 CI-CD 服务器。
假设您有以下需求:
这些是要遵循的步骤:
当 运行 pub publish
:
时注意这一点
When we run this command in our terminal for the first time, pub
would ask us to log in to our pub.dev account by
opening the URL printed on the command line. Once we log in using
that URL, pub
store some login credentials (which happens to be
some tokens) into a file called credentials.json
.
Next time when you run pub publish
command, it checks for this file
and proceeds further without asking for login again. This gave me a
hint that to make it work on CI-CD servers, we need to create this
file somehow on the build machine.
您可以访问博客“Publish Your Flutter/Dart Package using GitHub Actions”以获取有关上述每个步骤的更多详细信息。
我正在尝试使用 dart pub publish
在 Github 操作中自动发布一个包,但为此我需要登录。登录工作流程需要用户交互(通过 Google 登录),因此不能在 CI.
根据 https://github.com/dart-lang/pub/issues/2227 似乎没有简单的方法,但有人提到:
Having to put the path like run:
echo ${{secrets.PUB_CREDENTIALS}} > /opt/hostedtoolcache/flutter/1.9.1-hotfix.2-stable/x64/.pub-cache/credentials.json
is not really great to maintain.
这个 credentials.json
的格式是否已知?
编辑:在 Windows 上,the credentials.json
文件不在 C:\Users\<USER>\AppData\Roaming\Pub\Cache\credentials.json
中,如博客 post 中所述,它现在在 C:\Users\<USER>\AppData\Roaming\dart\pub-credentials.json
.
This medium post has a clear guide that could help you on publishing Flutter or Dart packages to pub.dev 通过 CI-CD 服务器。
假设您有以下需求:
这些是要遵循的步骤:
当 运行 pub publish
:
When we run this command in our terminal for the first time,
pub
would ask us to log in to our pub.dev account by opening the URL printed on the command line. Once we log in using that URL,pub
store some login credentials (which happens to be some tokens) into a file calledcredentials.json
.Next time when you run
pub publish
command, it checks for this file and proceeds further without asking for login again. This gave me a hint that to make it work on CI-CD servers, we need to create this file somehow on the build machine.
您可以访问博客“Publish Your Flutter/Dart Package using GitHub Actions”以获取有关上述每个步骤的更多详细信息。