semantic-release / github

:octocat: semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues
https://www.npmjs.com/package/@semantic-release/github
MIT License
419 stars 128 forks source link

ReleaseAsset: already_exists #295

Open TwoTenPvP opened 4 years ago

TwoTenPvP commented 4 years ago

I'm having issues when trying to publish on one of my projects. Error code below:

[10:32:03 PM] [semantic-release] » ×  An error occurred while running semantic-release: { HttpError: Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
    at response.text.then.message (C:\Users\appveyor\AppData\Roaming\npm\node_modules\semantic-release\node_modules\@octokit\request\dist-node\index.js:66:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HttpError',
  status: 422,
  headers:
   { 'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '204',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Tue, 10 Nov 2020 22:32:03 GMT',
     'strict-transport-security': 'max-age=31557600',
     vary: 'Accept-Encoding, Accept, X-Requested-With',
     'x-accepted-oauth-scopes': 'repo',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': 'E37F:7F3E:DC8D:FF81:5FAB14E2',
     'x-oauth-scopes': 'public_repo',
     'x-xss-protection': '1; mode=block' },
  request:
   { method: 'POST',
     url:
      'https://uploads.github.com/repos/MidLevel/Ruffles/releases/33757811/assets?name=net35.zip&',
     headers:
      { accept: 'application/vnd.github.v3+json',
        'user-agent':
         'octokit-rest.js/17.11.2 octokit-core.js/2.5.4 Node.js/10.22.0 (Windows Server 2016; ia32)',
        'content-type': 'application/zip',
        'content-length': 52529,
        authorization: 'token [REDACTED]' },
     body:
      <Buffer 50 4b 03 04 14 00 00 00 08 00 d9 b3 6a 51 0c 85 bd d1 70 8d 00 00 00 94 01 00 0b 00 00 00 52 75 66 66 6c 65 73 2e 64 6c 6c d4 1d 09 78 54 c5 f9 ed db ... >,
     request: { agent: undefined, hook: [Function: bound bound register] } },
  request_id: 'E37F:7F3E:DC8D:FF81:5FAB14E2',
  documentation_url: 'https://docs.github.com/rest',
  errors:
   [ { resource: 'ReleaseAsset',
       code: 'already_exists',
       field: 'name' } ],
  attemptNumber: 4,
  retriesLeft: 0,
  pluginName: '@semantic-release/github' }
{ HttpError: Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
    at response.text.then.message (C:\Users\appveyor\AppData\Roaming\npm\node_modules\semantic-release\node_modules\@octokit\request\dist-node\index.js:66:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
  name: 'HttpError',
  status: 422,
  headers:
   { 'cache-control': 'no-cache',
     connection: 'close',
     'content-length': '204',
     'content-security-policy': 'default-src \'none\'',
     'content-type': 'application/json; charset=utf-8',
     date: 'Tue, 10 Nov 2020 22:32:03 GMT',
     'strict-transport-security': 'max-age=31557600',
     vary: 'Accept-Encoding, Accept, X-Requested-With',
     'x-accepted-oauth-scopes': 'repo',
     'x-content-type-options': 'nosniff',
     'x-frame-options': 'deny',
     'x-github-media-type': 'github.v3; format=json',
     'x-github-request-id': 'E37F:7F3E:DC8D:FF81:5FAB14E2',
     'x-oauth-scopes': 'public_repo',
     'x-xss-protection': '1; mode=block' },
  request:
   { method: 'POST',
     url:
      'https://uploads.github.com/repos/MidLevel/Ruffles/releases/33757811/assets?name=net35.zip&',
     headers:
      { accept: 'application/vnd.github.v3+json',
        'user-agent':
         'octokit-rest.js/17.11.2 octokit-core.js/2.5.4 Node.js/10.22.0 (Windows Server 2016; ia32)',
        'content-type': 'application/zip',
        'content-length': 52529,
        authorization: 'token [REDACTED]' },
     body:
      <Buffer 50 4b 03 04 14 00 00 00 08 00 d9 b3 6a 51 0c 85 bd d1 70 8d 00 00 00 94 01 00 0b 00 00 00 52 75 66 66 6c 65 73 2e 64 6c 6c d4 1d 09 78 54 c5 f9 ed db ... >,
     request: { agent: undefined, hook: [Function: bound bound register] } },
  request_id: 'E37F:7F3E:DC8D:FF81:5FAB14E2',
  documentation_url: 'https://docs.github.com/rest',
  errors:
   [ { resource: 'ReleaseAsset',
       code: 'already_exists',
       field: 'name' } ],
  attemptNumber: 4,
  retriesLeft: 0,
  pluginName: '@semantic-release/github' }
Command exited with code 1
leosuncin commented 3 years ago

Same error happens to me https://github.com/leosuncin/koa-api-example/runs/3904015941

gpspake commented 2 years ago

I'm getting the same error in two separate projects. One's using Jenkins and one's using Github actions. In both cases, the publish works (it actually gets published to github) but CI fails because of this error. I haven't had much luck figuring out what's happening. Glad I'm not the only one 🙂

Here's the output from the github action for this repo: https://github.com/gpspake/npm-demo-shared-dependency

....
[9:50:13 PM] [semantic-release] [@semantic-release/npm] › ℹ  Publishing version 1.1.3 to npm registry on dist-tag latest
npm notice 
npm notice 📦  @spake/npm-demo-shared-dependency@1.1.3
npm notice === Tarball Contents === 
npm notice 342B  index.js         
npm notice 190B  math/index.js    
npm notice 778B  package.json     
npm notice 337B  index.js.map     
npm notice 251B  math/index.js.map
npm notice 1.1kB CHANGELOG.md     
npm notice 24B   README.md        
npm notice === Tarball Details === 
npm notice name:          @spake/npm-demo-shared-dependency       
npm notice version:       1.1.3                                   
npm notice package size:  1.5 kB                                  
npm notice unpacked size: 3.0 kB                                  
npm notice shasum:        c1f3a729c71979303e8d658cb6bb4a027039aec8
npm notice integrity:     sha512-rhtyhEHJjfeXZ[...]ZBd0XPNtCr5kw==
npm notice total files:   7                                       
npm notice 
+ @spake/npm-demo-shared-dependency@1.1.3
[9:50:18 PM] [semantic-release] [@semantic-release/npm] › ℹ  Published @spake/npm-demo-shared-dependency@1.1.3 to dist-tag @latest on https://registry.npmjs.org/
[9:50:18 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/npm"
[9:50:18 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/github"
[9:50:18 PM] [semantic-release] [@semantic-release/github] › ✖  The asset dist/math is not a file, and will be ignored.
[9:50:21 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/gpspake/npm-demo-shared-dependency/releases/download/untagged-52ce1e2f05d5a142cec7/CHANGELOG.md
[9:50:24 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/gpspake/npm-demo-shared-dependency/releases/download/untagged-52ce1e2f05d5a142cec7/index.js
[9:50:27 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/gpspake/npm-demo-shared-dependency/releases/download/untagged-52ce1e2f05d5a142cec7/README.md
[9:50:30 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/gpspake/npm-demo-shared-dependency/releases/download/untagged-52ce1e2f05d5a142cec7/index.js.map
[9:50:33 PM] [semantic-release] [@semantic-release/github] › ℹ  Published file https://github.com/gpspake/npm-demo-shared-dependency/releases/download/untagged-52ce1e2f05d5a142cec7/package.json
[9:50:54 PM] [semantic-release] › ✖  Failed step "publish" of plugin "@semantic-release/github"
[9:50:54 PM] [semantic-release] › ✖  An error occurred while running semantic-release: RequestError [HttpError]: Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
    at /home/runner/.npm/_npx/1723/lib/node_modules/semantic-release/node_modules/@octokit/request/dist-node/index.js:86:21
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  status: 422,
  response: {
    url: 'https://uploads.github.com/repos/gpspake/npm-demo-shared-dependency/releases/57617309/assets?name=index.js&',
    status: 422,
    headers: {
      'cache-control': 'no-cache',
      connection: 'close',
      'content-length': '208',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 20 Jan 2022 21:50:54 GMT',
      'strict-transport-security': 'max-age=31557600',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '0402:0AC2:14382C:1A70A8:61E9D93E',
      'x-xss-protection': '1; mode=block'
    },
    data: {
      message: 'Validation Failed',
      request_id: '0402:0AC2:14382C:1A70A8:61E9D93E',
      documentation_url: 'https://docs.github.com/rest',
      errors: [Array]
    }
  },
  request: {
    method: 'POST',
    url: 'https://uploads.github.com/repos/gpspake/npm-demo-shared-dependency/releases/57617309/assets?name=index.js&',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/18.12.0 octokit-core.js/3.5.1 Node.js/14.18.3 (linux; x64)',
      'content-type': 'application/javascript',
      'content-length': 190,
      authorization: 'token [REDACTED]'
    },
    body: <Buffer 22 75 73 65 20 73 74 72 69 63 74 22 3b 4f 62 6a 65 63 74 2e 64 65 66 69 6e 65 50 72 6f 70 65 72 74 79 28 65 78 70 6f 72 74 73 2c 22 5f 5f 65 73 4d 6f ... 140 more bytes>,
    request: { agent: undefined, hook: [Function: bound bound register] }
  },
  attemptNumber: 4,
  retriesLeft: 0,
  pluginName: '@semantic-release/github'
}
RequestError [HttpError]: Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
    at /home/runner/.npm/_npx/1723/lib/node_modules/semantic-release/node_modules/@octokit/request/dist-node/index.js:86:21
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  status: 422,
  response: {
    url: 'https://uploads.github.com/repos/gpspake/npm-demo-shared-dependency/releases/57617309/assets?name=index.js&',
    status: 422,
    headers: {
      'cache-control': 'no-cache',
      connection: 'close',
      'content-length': '208',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Thu, 20 Jan 2022 21:50:54 GMT',
      'strict-transport-security': 'max-age=31557600',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': '0402:0AC2:14382C:1A70A8:61E9D93E',
      'x-xss-protection': '1; mode=block'
    },
    data: {
      message: 'Validation Failed',
      request_id: '0402:0AC2:14382C:1A70A8:61E9D93E',
      documentation_url: 'https://docs.github.com/rest',
      errors: [Array]
    }
  },
  request: {
    method: 'POST',
    url: 'https://uploads.github.com/repos/gpspake/npm-demo-shared-dependency/releases/57617309/assets?name=index.js&',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/18.12.0 octokit-core.js/3.5.1 Node.js/14.18.3 (linux; x64)',
      'content-type': 'application/javascript',
      'content-length': 190,
      authorization: 'token [REDACTED]'
    },
    body: <Buffer 22 75 73 65 20 73 74 72 69 63 74 22 3b 4f 62 6a 65 63 74 2e 64 65 66 69 6e 65 50 72 6f 70 65 72 74 79 28 65 78 70 6f 72 74 73 2c 22 5f 5f 65 73 4d 6f ... 140 more bytes>,
    request: { agent: undefined, hook: [Function: bound bound register] }
  },
  attemptNumber: 4,
  retriesLeft: 0,
  pluginName: '@semantic-release/github'
}
Error: Process completed with exit code 1.
TaylorHo commented 8 months ago

I was with the same issue. Seeing the draft issue generated I understand that the published assets are all published as single files, not as a folder structure.

My way to deal with it was adding a script to compress the dist/build folder before publishing, and then adding this compressed generated file to the @semantic-release/github, publishing only a single compressed file.

It would be so better if @semantic-release/github already had an option for compressing the dist/build folder, but as troubleshooting we can do it this way.

Also, if you're with this problem take a look at the logs and the files that are being tried to be uploaded to the release. This way I could deal with the error.