jreleaser / jreleaser

:rocket: Release projects quickly and easily with JReleaser
https://jreleaser.org
Apache License 2.0
925 stars 106 forks source link

[packagers] Publishing to Homebrew fails with unexpected error without further explanation #1034

Open maciejwalkowiak opened 1 year ago

maciejwalkowiak commented 1 year ago

Publishing to Homebrew fails with:

Unexpected error
Unexpected error updating maciejwalkowiak/homebrew-tap

when running through Github actions.

Output from: https://github.com/maciejwalkowiak/yolo/actions/runs/3418569714/jobs/5691146097

Run echo "☕ java -jar jreleaser-cli.jar full-release"
☕ java -jar jreleaser-cli.jar full-release
jreleaser 1.3.1. Consider becoming a patron at https://www.patreon.com/aalmiray
[INFO]  JReleaser 1.3.1
[INFO]  Configuring with jreleaser.yml
[INFO]    - basedir set to /home/runner/work/yolo/yolo
[INFO]  Reading configuration
[INFO]  Loading variables from /home/runner/.jreleaser/config.properties
[WARN]  Variables source /home/runner/.jreleaser/config.properties does not exist
[INFO]  Validating configuration
[INFO]  Project version set to 0.1.0
[INFO]  Release is not snapshot
[INFO]  Timestamp is 2022-11-08T10:41:11.950478451Z
[INFO]  HEAD is at 66e1f1e
[INFO]  Platform is linux-x86_64
[INFO]  dry-run set to false
[INFO]  Generating changelog
[INFO]  Storing changelog: out/jreleaser/release/CHANGELOG.md
[INFO]  Calculating checksums
[INFO]    [checksum] bin/yolo-amd64-linux.zip.sha256
[INFO]    [checksum] bin/yolo-amd64-darwin.zip.sha256
[INFO]    [checksum] bin/yolo-amd64.zip.sha256
[INFO]  Signing files
[INFO]    [sign] Signing is not enabled. Skipping
[INFO]  Deploying is not enabled. Skipping
[INFO]  Uploading is not enabled. Skipping
[INFO]  Releasing to https://github.com/maciejwalkowiak/yolo
[INFO]   - uploading yolo-amd64-linux.zip
[INFO]   - uploading yolo-amd64-darwin.zip
[INFO]   - uploading yolo-amd64.zip
[INFO]   - uploading checksums_sha256.txt
[INFO]  Preparing distributions
[INFO]    - Preparing yolo distribution
[INFO]      [brew] preparing yolo distribution
[INFO]  Packaging distributions
[INFO]    - Packaging yolo distribution
[INFO]      [brew] packaging yolo distribution
[INFO]  Publishing distributions
[INFO]    - Publishing yolo distribution
[INFO]      [brew] publishing yolo distribution
[INFO]      [brew] setting up repository maciejwalkowiak/homebrew-tap
[INFO]      [brew] pushing to maciejwalkowiak/homebrew-tap
[INFO]  Writing output properties to out/jreleaser/output.properties
Error:  JReleaser failed after 5.[77](https://github.com/maciejwalkowiak/yolo/actions/runs/3418569714/jobs/5691146097#step:5:83)7 s
Unexpected error
Unexpected error updating maciejwalkowiak/homebrew-tap
Error: Process completed with exit code 1.

Running the same command from my localhost works. Perhaps the error logs could be improved to clearly states why does the publishing fails.

aalmiray commented 1 year ago

Did you configure a personal Git token? The default secrets.GITHUB_TOKEN won't work for cross posting to a different git repository (homebrew-tap).

maciejwalkowiak commented 1 year ago

Nope, thats probably it! Thanks will try in the next release and will post here if it worked or not.

Anyways, I think the error could be improved (perhaps with exactly the same suggestion as you have commented).

aalmiray commented 1 year ago

Do you have access to the out/jreleaser/trace.log? If so the full stacktrace may contain a hint to let JReleaser know what to do.

aalmiray commented 1 year ago

FWIW the docs cover the requirement for a PAT https://jreleaser.org/guide/latest/configuration/packagers/homebrew.html#_tokens but I agree the error message could be improved as well.

maciejwalkowiak commented 1 year ago

Not really as it's running on Github actions. Probably there is a way to access it but I think its not trivial (?) Perhaps there could be a flag to JReleaser to run in verbose mode to print it all to STDOUT?

aalmiray commented 1 year ago

You can grab the logs and store them

      - name: JReleaser release output
        if: always()
        uses: actions/upload-artifact@v3
        with:
          name: jreleaser-release
          path: |
            out/jreleaser/trace.log
            out/jreleaser/output.properties

You may also configure debug mode when running the action to print everything to STDOUT

      - name: Release
        uses: jreleaser/release-action@v2
        with:
          arguments: full-release -g
aalmiray commented 1 year ago

Full stacktrace when attempting to update a tap repository using a GitHub token with insufficient permissions:

org.jreleaser.model.JReleaserException: Unexpected error
    at org.jreleaser.engine.distribution.Distributions.processPackager(Distributions.java:145)
    at org.jreleaser.engine.distribution.Distributions.processDistribution(Distributions.java:111)
    at org.jreleaser.engine.distribution.Distributions.process(Distributions.java:95)
    at org.jreleaser.workflow.PublishWorkflowItem.doInvoke(PublishWorkflowItem.java:37)
    at org.jreleaser.workflow.AbstractWorkflowItem.lambda$invoke$0(AbstractWorkflowItem.java:43)
    at org.jreleaser.engine.hooks.CommandHookExecutor.execute(CommandHookExecutor.java:52)
    at org.jreleaser.workflow.AbstractWorkflowItem.invoke(AbstractWorkflowItem.java:43)
    at org.jreleaser.workflow.WorkflowImpl.execute(WorkflowImpl.java:102)
    at org.jreleaser.cli.Publish.doExecute(Publish.java:90)
    at org.jreleaser.cli.AbstractModelCommand.execute(AbstractModelCommand.java:85)
    at org.jreleaser.cli.AbstractCommand.call(AbstractCommand.java:36)
    at org.jreleaser.cli.AbstractModelCommand.call(AbstractModelCommand.java:48)
    at org.jreleaser.cli.AbstractCommand.call(AbstractCommand.java:29)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2041)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2461)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2453)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2415)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2273)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2417)
    at picocli.CommandLine.execute(CommandLine.java:2170)
    at org.jreleaser.cli.Main.execute(Main.java:72)
    at org.jreleaser.cli.Main.run(Main.java:57)
    at org.jreleaser.cli.Main.main(Main.java:48)
Caused by: org.jreleaser.model.spi.packagers.PackagerProcessingException: Unexpected error updating aalmiray/homebrew-test
    at org.jreleaser.packagers.AbstractRepositoryPackagerProcessor.doPublishDistribution(AbstractRepositoryPackagerProcessor.java:138)
    at org.jreleaser.packagers.AbstractPackagerProcessor.publishDistribution(AbstractPackagerProcessor.java:182)
    at org.jreleaser.packagers.BrewPackagerProcessor.publishDistribution(BrewPackagerProcessor.java:74)
    at org.jreleaser.engine.distribution.DistributionProcessor.publishDistribution(DistributionProcessor.java:141)
    at org.jreleaser.engine.distribution.Distributions.processPackager(Distributions.java:140)
    ... 23 more
Caused by: org.kohsuke.github.GHFileNotFoundException: https://api.github.com/user/repos {"message":"Not Found","documentation_url":"https://docs.github.com/rest/reference/repos#create-a-repository-for-the-authenticated-user"}
    at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:480)
    at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:407)
    at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:355)
    at org.kohsuke.github.Requester.fetch(Requester.java:76)
    at org.kohsuke.github.AbstractBuilder.done(AbstractBuilder.java:108)
    at org.kohsuke.github.GHRepositoryBuilder.done(GHRepositoryBuilder.java:242)
    at org.kohsuke.github.GHCreateRepositoryBuilder.done(GHCreateRepositoryBuilder.java:12)
    at org.kohsuke.github.GHCreateRepositoryBuilder.create(GHCreateRepositoryBuilder.java:132)
    at org.jreleaser.sdk.github.Github.createRepository(Github.java:139)
    at org.jreleaser.sdk.github.GithubReleaser.maybeCreateRepository(GithubReleaser.java:258)
    at org.jreleaser.packagers.AbstractRepositoryPackagerProcessor.doPublishDistribution(AbstractRepositoryPackagerProcessor.java:69)
    ... 27 more
Caused by: java.io.FileNotFoundException: https://api.github.com/user/repos
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1974)
    at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1969)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1968)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
    at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.bodyStream(GitHubHttpUrlConnectionClient.java:174)
    at org.kohsuke.github.GitHubResponse$ResponseInfo.getBodyAsString(GitHubResponse.java:314)
    at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:92)
    at org.kohsuke.github.Requester.lambda$fetch$1(Requester.java:76)
    at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:449)
    at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:399)
    ... 36 more
Caused by: java.io.FileNotFoundException: https://api.github.com/user/repos
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1920)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
    at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:527)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:334)
    at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:63)
    at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:387)
    ... 36 more
aalmiray commented 1 year ago

Related https://github.com/jreleaser/jreleaser/issues/791