Issue
I would like to know if anyone can provide a nice answer to:
How can I publish a dart package on https://pub.dartlang.org/ during the deploy step, for example on a certain tag or even specified branch?
I have figured that I can run a script as a provider but I assume that the access token is required for pub I guess? Its not super clear so then I decided to ask here. For even more detailed context, my project is here and I would like to tag a release and have it publish like npm release.
Thanks.
Solution
Thanks to the comments I found that the following did solve the issue…
- Added a section to the
.travis.yml
to set the deploy script, I changed to branch just for this example since I messed up the tag example
deploy: provider: script script: ./tool/publish.sh on: branch: master
- Setup some
publish.sh
that writes the json out
#!/usr/bin/env bash mkdir -p .pub-cache cat <<EOF > ~/.pub-cache/credentials.json { "accessToken":"$accessToken", "refreshToken":"$refreshToken", "tokenEndpoint":"$tokenEndpoint", "scopes":["$scopes"], "expiration":$expiration } EOF pub publish -f
- Set the env variables in travis settings for the repo with the show in build disabled.
Only thing now is if it will work after expiry…
Answered By – LTeacher
Answer Checked By – David Goodson (FlutterFixes Volunteer)