dbuenzli / topkg

The transitory OCaml software packager
http://erratique.ch/software/topkg
ISC License
69 stars 25 forks source link

topkg publish failure #125

Closed grayswandyr closed 6 years ago

grayswandyr commented 6 years ago

Hi

I'm just switched to Dune and I'm now trying to publish an OPAM package using topkg. My repo is here. It seems everything goes well until reaching:

~/Electrod $ topkg publish -vv
topkg: [INFO] topkg v0.9.1 running
topkg: [EXEC:13882] ['ocaml' 'pkg/pkg.ml' 'ipc' 'debug'
                     '/tmp/topkgae84e9topkg' 'pkg']
pkg.ml: [INFO] topkg v0.9.1, running main
topkg: [EXEC] ['type' 'git' 1>'/dev/null' 2>'/dev/null']
topkg: [EXEC] ['git' 'rev-parse' '--git-dir' 1>'/tmp/topkgd3efbctopkg' 2>'/dev/null']
topkg: [EXEC] ['git' '--git-dir' '.git' '--work-tree' '.' 'describe' '--always' 'HEAD' 1>'/tmp/topkg052ac5topkg']
topkg: [EXEC] ['git' 'rev-parse' '--git-dir' 1>'/tmp/topkg711510topkg' 2>'/dev/null']
topkg: [EXEC] ['git' '--git-dir' '.git' '--work-tree' '.' 'describe' '--always' 'HEAD' 1>'/tmp/topkg4a67f6topkg']
topkg: [INFO] Parsing opam file electrod.opam
topkg: [EXEC] ['git' 'rev-parse' '--git-dir' 1>'/tmp/topkg07fa7dtopkg' 2>'/dev/null']
topkg: [EXEC] ['git' '--git-dir' '.git' '--work-tree' '.' 'describe' '--always' 'HEAD' 1>'/tmp/topkg66bf12topkg']
topkg: [EXEC:13896] ['toy-github-topkg-delegate' 'ipc' 'debug' 'publish'
                     'distrib'
                     'https://github.com/grayswandyr/electrod/releases/download/0.1.2/electrod-0.1.2.tbz'
                     'electrod' '0.1.2'
                     '### 0.1.2 (2018-01-24)
- First OPAM (tentative) release
- Joint switch to Jbuilder/Dune'
                     '~/REPOS/Electrod/electrod-dev/_build/electrod-0.1.2.tbz']
toy-github-topkg-delegate: [EXEC] ['type' 'git' 1>'/dev/null' 2>'/dev/null']
toy-github-topkg-delegate: [EXEC] ['git' 'rev-parse' '--git-dir' 1>'/tmp/toy-github-topkg-delegatebdde50topkg' 2>'/dev/null']
toy-github-topkg-delegate: [EXEC:13900] ['git' '--git-dir' '.git' 'push'
                                         '--force' '--tags']
Everything up-to-date
toy-github-topkg-delegate: [EXEC:13909] ['opam' 'config' 'var' 'root']
toy-github-topkg-delegate: [EXEC:13912] ['curl' '-s' '-S' '-K' '-' '-D' '-'
                                         '--data'
                                         '{ "tag_name" : "0.1.2", "body" : "### 0.1.2 (2018-01-24)\n- First OPAM (tentative) release\n- Joint switch to Jbuilder/Dune" }'
                                         'https://api.github.com/repos/grayswandyr/electrod/releases']
toy-github-topkg-delegate: [ERROR] Could not find release id in
                                   response:
                                   HTTP/1.0 200 Connection
                                   Established
                                   Proxy-agent: Apache/2.4.29 (Unix)

                                   HTTP/1.1 401 Unauthorized
                                   Server: GitHub.com
                                   Date: Wed, 24 Jan 2018 14:45:16
                                   GMT
                                   Content-Type: application/json;
                                   charset=utf-8
                                   Content-Length: 93
                                   Status: 401
                                   Unauthorized
                                   X-GitHub-Media-Type: github.v3;
                                   format=json
                                   X-RateLimit-Limit:
                                   60
                                   X-RateLimit-Remaining:
                                   51
                                   X-RateLimit-Reset:
                                   1516806217
                                   Access-Control-Expose-Headers: ETag, Link,
                                   Retry-After, X-GitHub-OTP,
                                   X-RateLimit-Limit, X-RateLimit-Remaining,
                                   X-RateLimit-Reset, X-OAuth-Scopes,
                                   X-Accepted-OAuth-Scopes,
                                   X-Poll-Interval
                                   Access-Control-Allow-Origin:
                                   *
                                   Content-Security-Policy: default-src
                                   'none'
                                   Strict-Transport-Security:
                                   max-age=31536000; includeSubdomains;
                                   preload
                                   X-Content-Type-Options:
                                   nosniff
                                   X-Frame-Options: deny
                                   X-XSS-Protection: 1;
                                   mode=block
                                   X-Runtime-rack:
                                   0.084972
                                   X-GitHub-Request-Id:
                                   8D9C:78BA:948151:1B88A0B:5A689BFC

                                   {
                                     "message": "Bad credentials",
                                     "documentation_url":
                                   "https://developer.github.com/v3"
                                   }
                                   .
topkg: [ERROR] Delegate toy-github-topkg-delegate errored with 2

I suppose I'm doing something wrong but I can't find what. FWIW, I work behing a proxy...

dbuenzli commented 6 years ago

"message": "Bad credentials",

It seems you have a github authentication failure. See toy-github-topkg-delegate --help to see how it is performed.

grayswandyr commented 6 years ago

Thanks, the Github token was wrong (I had used opam-publish but it hadn't worked, and I don't know how it got a token itself), I just overwrote it with a freshly-generated one and it worked.

Now topkg opam submit complains that the name and version are present in the opam file... I didn't had the version field myself, I thought it was precisely the purpose of a topkg subcommand to add it by itself... I guess I don't understand the workflow fully yet (I would love comments here). Here is what I did:

git flow release start 0.1.2  # git flow creates a branch for 0.1.2, to prepare a release cleanly
... editing CHANGES.md and a few other files...
git commit -am "..."
git flow finish   # merges back in master, switch to master
git push github    # the github remote 
git push --tags github
topkg distrib
topkg publish   # fixed thanks to you
topkg opam pkg

And then:

$ topkg opam submit
Submitting _build/electrod.0.1.2
[electrod-0.1.2.tbz] http://github.com/grayswandyr/electrod/releases/download/0.1.2/electrod-0.1.2.tbz downloaded
[ERROR] In /home/dchemoui/REPOS/Electrod/electrod-dev/_build/electrod.0.1.2/opam:
          warning 99: should not contain 'name' or 'version' fields

Go on submitting, ignoring the warnings ? [Y/n] n
Aborting
dbuenzli commented 6 years ago

Remove this line from your opam file.

The workflow is described in topkg help release.

grayswandyr commented 6 years ago

OK. Sorry I don't recall reading that the name should not be present either. I guess I should create a new version now as the tag has already been pushed? Besides, when does watermarking take effect? Is it in topkg distrib? (If so, I think it would be nice ton mention this in the release help.) Pushing is handled by topkg publish?

dbuenzli commented 6 years ago

OK. Sorry I don't recall reading that the name should not be present either.

It's not written there but OTOH the opam lint message is quite clear. In general you can safely assume that you should not have name: or version: fields in opam files.

Is it in topkg distrib?

Yes the details of what happens are here.

(topkg's documentation is not well organized, next time I'll put less in the manpages and direct to the API docs so that things can be properly hyperlinked, especially now that we have odoc manuals).

grayswandyr commented 6 years ago

OK thank you again for your help and your work. Just for the record, concerning linting, I had done it:

~/Electrod $ cat electrod.opam 
opam-version: "1.2"
name: "electrod"
maintainer: "David Chemouil <david.chemouil+git@onera.fr>"
authors: ["David Chemouil" "Julien Brunel"]
homepage: "https://github.com/grayswandyr/electrod/"
bug-reports: "https://github.com/grayswandyr/electrod/issues"
license: "MPL-2.0"
dev-repo: "https://github.com/grayswandyr/electrod.git"
build: [
  ["jbuilder" "subst" "-p" name] {pinned}
  ["jbuilder" "build" "-p" name "-j" jobs]
]
depends: [
  "ocamlfind" {build}
  "jbuilder" {build & >="1.0+beta9"}
  "topkg" {build & >= "0.9.0"} 
  "cmdliner" 
  "containers" 
  "fmt" 
  "gen" 
  "hashcons" 
  "logs" 
  "menhir" 
  "mtime" 
  "ppx_blob"
  "ppx_deriving" 
  "printbox"
  "sequence" 
  "visitors" 
]
available: [ocaml-version >= "4.04"]
~/Electrod $ opam lint electrod.opam
~/REPOS/Electrod/electrod-dev/electrod.opam: Passed.
~/Electrod $ topkg lint
[ OK ] File CHANGES.md is present.
[ OK ] File LICENSE.md is present.
[ OK ] File README.md is present.
[ OK ] File electrod.opam is present.
[ OK ] lint opam file electrod.opam.
[ OK ] lint /home/dchemoui/REPOS/Electrod/electrod-dev success
dbuenzli commented 6 years ago

Yes unfortunately opam lint differs from the linting done by opam publish submit (which is the command behind topkg opam submit, I thought there was an issue somewhere upstream but I can't find it. I think it would be good to report it to opam.

grayswandyr commented 6 years ago

OK I will report this.