saitho/semantic-release-gitea

Crash on Start step "publish"

Closed this issue · 12 comments

ViRb3 commented

Issue

The new version is successfully tagged, the release is created as draft, and semantic-release stops at "publishing". No assets are uploaded even though they exist, and the release remains as draft for the time being. For debugging I added a wildcard "*" for assets, but not a single file out of my whole repo is uploaded. Adding --debug shows no more information on the publish step. Am I missing something obvious? Thanks!

Environment

Key Version
Gitea 1.11.6
semantic-release 17.0.8
OS Ubuntu 20.04 arm64
CI Drone 1.8.0

Config

GITEA_TOKEN and GITEA_URL are set through env vars

{
    "plugins": [
        "@semantic-release/commit-analyzer",
        "@semantic-release/release-notes-generator",
        [
            "@saithodev/semantic-release-gitea",
            {
                "assets": [
                    {
                        "path": "*"
                    }
                ]
            }
        ]
    ]
}

CI log (excerpt)

[11:44:33 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[11:44:37 PM] [semantic-release] › ✔  Created tag v1.0.0
11:44:37 PM] [semantic-release] › ℹ  Start step "publish" of plugin 
"@saithodev/semantic-release-gitea"
[11:44:38 PM] [semantic-release] [@saithodev/semantic-release-gitea] › ✖  The asset src is not a file, and will be ignored.
[11:44:38 PM] [semantic-release] [@saithodev/semantic-release-gitea] › ✖  The asset gradle is not a file, and will be ignored.
[11:44:38 PM] [semantic-release] [@saithodev/semantic-release-gitea] › ✖  The asset build is not a file, and will be ignored.

Gitea log (excerpt)

I noticed a bunch of 401s along the log when it was time for assets to upload, not sure if this is the root of the problem.

[Macaron] 2020-06-14 00:09:42: Started   GET /user/repo.git/info/refs?service=git-upload-pack for xxx.xxx.xxx.xxx
[Macaron] 2020-06-14 00:09:42: Completed GET /user/repo.git/info/refs?service=git-upload-pack 401 Unauthorized in 8.377956ms
[Macaron] 2020-06-14 00:09:42: Started   GET /user/repo.git/info/refs?service=git-upload-pack for xxx.xxx.xxx.xxx
[Macaron] 2020-06-14 00:09:42: Completed GET /user/repo.git/info/refs?service=git-upload-pack 200 OK in 32.291874ms
[Macaron] 2020-06-14 00:09:42: Started   GET /user/repo.git/info/refs?service=git-upload-pack for xxx.xxx.xxx.xxx
[Macaron] 2020-06-14 00:09:42: Completed GET /user/repo.git/info/refs?service=git-upload-pack 401 Unauthorized in 8.095144ms

When uploading assets a draft release is created first which is converted into a regular release when the assets are uploaded.

I don't think you Gitea log is related to this issue, as git-upload-pack seems to be used during git fetch according to Git docs

Just from looking at the logs I can see you're trying to add a folder as asset which does not work. You can only upload files. IMHO it should still publish releases when it skipped files.

I'll look into that. I'm currently setting up a testing environment which can hopefully be used for automated acceptance testing.

ViRb3 commented

The logs I provided are from the "*" glob test - if I add a file name it will just skip it and log nothing at all, so semantic-release exits at Start step "publish" of plugin .... It is worth noting that if I leave out the assets configuration then I get the expected Completed step "publish" of plugin ... and the draft gets converted to full release, making me think that it crashes otherwise. If there's any way I can help please let me know.

@ViRb3 Are there any more error messages in the CI log?
Gitea does not allow certain file types, e.g. txt, images, etc.
I'm looking for an error message like below:

[11:29:27 AM] [semantic-release] › ℹ Start step "publish" of plugin "@saithodev/semantic-release-gitea"
--
33 | [11:29:27 AM] [semantic-release] [@saithodev/semantic-release-gitea] › ✖ The asset src is not a file, and will be ignored.
34 | [11:29:28 AM] [semantic-release] [@saithodev/semantic-release-gitea] › ℹ API error while publishing file .drone.yml
35 | [11:29:28 AM] [semantic-release] › ✖ Failed step "publish" of plugin "@saithodev/semantic-release-gitea"
36 | [11:29:28 AM] [semantic-release] › ✖ EGITEAAPIERROR Gitea API reported an error.
37 | Gitea API reported the following error: File type is not allowed: text/plain; charset=utf-8.
38 |  
39 | SemanticReleaseError: Gitea API reported an error.
40 | at module.exports (/drone/src/node_modules/@saithodev/semantic-release-gitea/lib/get-error.js:6:10)
41 | at /drone/src/node_modules/@saithodev/semantic-release-gitea/lib/publish.js:86:21
42 | at processTicksAndRejections (internal/process/task_queues.js:97:5) {
43 | code: 'EGITEAAPIERROR',
44 | details: 'Gitea API reported the following error: File type is not allowed: text/plain; charset=utf-8.',
45 | semanticRelease: true,
46 | pluginName: '@saithodev/semantic-release-gitea'
47 | [11:29:28 AM] [semantic-release] [@saithodev/semantic-release-gitea] › ℹ API error while publishing file .gitignore
48 | [11:29:28 AM] [semantic-release] [@saithodev/semantic-release-gitea] › ℹ API error while publishing file favicon.ico
49 | }

You'd have to exclude those files from the scope, like so:
"path": ["*", "!*.json", "!*.yml"]

ViRb3 commented

I have disabled attachment restrictions in the gitea.ini file:

[attachment]
PATH = /data/gitea/attachments
ALLOWED_TYPES = */*
MAX_SIZE = 1000

I can confirm that I can upload any kind of file manually via the web interface. There are no other log messages on my end.

On other projects I use Drone CI release plugin for Gitea and goreleaser for Gitea and they both work just fine as well.

Is your repository publicly available so I can try it myself?
Or can you prepare a reduced sample repository that also fails with your configuration?

So far I allowed all types on my Gitea and used the glob "*" as file path in semantic-release configuration. Worked fine for me - all files were attached to the release:

working-release

I've uploaded the repository I used here: https://github.com/saitho/gitea-semantic-release-test
If you want to test it, make sure to adjust the Gitea URL in .releaserc.json. :)

ViRb3 commented

Thanks so much for producing a whole test repo, I am testing it as we speak. I have sent an e-mail to your GitHub profile email to ask if we can connect in private, that I way I can provide you access to my Gitea instance if the issue remains unsolved.

ViRb3 commented

Good news, your test repo published all of the assets just fine! I will start porting my original repo to your repo format step by step and see what breaks it. I will update here accordingly.

Nice, I'm glad to hear that! :)

ViRb3 commented

Quite shockingly, the problem is in the official Docker image node:13. Once I changed it for anything else (like your image or node:14), everything works as normal. For exact reproduction, the offending Docker image id is a9a6e47960b0.

My JavaScript/NPM skills are very limited, but how come no error message or any other indication was displayed? Does this mean that Node 13 is unsupported by semantic-release or your plugin? Not that I will ever use Node 13 again, it would just be helpful for troubleshooting in the future.

semantic-release states compatibility from Node 10.18 and above.
The current LTS (Long-Term-Support) version is Node 12, so there may be some issues with later non-LTS versions (13 and 14).

I'll try to do some testing with those versions next week and add a note in the README. :)

ViRb3 commented

I just tried your test repo with the GitHub plugin, and both Node 13 and Node 14 work fine. This leads me to believe that it may be a bug with this plugin. For reference, here is my GitHub test repo: https://github.com/ViRb3/gitea-semantic-release-test

There really seems to be a problem with Node 13, as the tests fail. Other Node versions work fine.
I'll create a new release 2.0.0 that can only be used with Node 10, 11, 12 and >=14.
=> #7