pubx icon indicating copy to clipboard operation
pubx copied to clipboard

Easy publish on CI env

Open jaumard opened this issue 6 years ago • 6 comments

Hello :)

I've open this issue on pub https://github.com/dart-lang/pub/issues/2227

But look like it will take time to be implemented properly, I think it can be done in this plugin until an official solution is available.

A pubx publish --token that will set the token into /.pub-cache/credentials.json and then forward the publish to pub.

What do you think ?

jaumard avatar Oct 24 '19 07:10 jaumard

Hi @jaumard,

I'm sorry. I just saw this now. I have to figure out my notification prefs.

Can you describe the command in full? What it's for, how it works, what are its options, etc?

shyndman avatar Dec 27 '19 15:12 shyndman

No problem :)

So I have some repo where I want to have automatic deployment in when I'm pushing a new tag for exemple, currently it's not really easy as we have to manually push our login/token into /.pub-cache/credentials.json to make the pub publish to work. If not it ask for a login and it's not possible on CI.

Here is what I have in my /.pub-cache/credentials.json:

{
  "accessToken": "TOKEN_VALUE",
  "refreshToken": "REFRESH_TOKEN_VALUE",
  "tokenEndpoint": "https://accounts.google.com/o/oauth2/token",
  "scopes": [
    "openid",
    "https://www.googleapis.com/auth/userinfo.email"
  ],
  "expiration": 1576674549551
}

So until pub give us an easy way to publish on ci we can have this command that create the /.pub-cache/credentials.json with that content and fill the accessToken and refreshToken (maybe update the expiration to always have a valid value)

So my idea is to have a command like:

pubx publish --access-token MY_SUPER_TOKEN --refresh-token MY_REFRESH_TOKEN

That command has two step to do:

  • Create/override /.pub-cache/credentials.json
  • call pub publish --force to publish the package on pub

Is it more clear @shyndman ?

jaumard avatar Dec 27 '19 15:12 jaumard

Yes. Thank you. I think this is a perfect addition.

Are you looking to contribute this functionality?

shyndman avatar Dec 27 '19 19:12 shyndman

One thought about --force: maybe we want to keep that option as well, and forward it along?

In its absence, fail the command with a non-zero exit if there are errors, so CI can be aware of any problems.

shyndman avatar Dec 27 '19 19:12 shyndman

is there progress here? I would like to automate pub publish as well.

AKushWarrior avatar Jun 22 '20 04:06 AKushWarrior

It looks like pub has not yet finalized their API spec for publishing stuff (see https://github.com/dart-lang/pub/issues/1381).

tianhaoz95 avatar Nov 12 '20 19:11 tianhaoz95