1

My default branch is main and while merging it to main branch I am getting this error. I have added env for NPM_TOKEN and GH_TOKEN in vercel environment variable.

vercel.json

{
"$schema": "https://openapi.vercel.sh/vercel.json",
"buildCommand": "yarn run build-storybook && yarn run semantic-release",
"devCommand": "yarn run storybook",
"installCommand": "yarn install",
"framework": null,
"outputDirectory": "./storybook-static"
}

package.json

"release": {
"branches": [
  "main",
  "next"
 ]
}

release.config.js

{
"branches": [
    {name: 'main'},
  ],
"plugins": [
  "@semantic-release/commit-analyzer",
  "@semantic-release/release-notes-generator",
  ["@semantic-release/github", {
    "assets": ["dist/**"]
    }],
  ["@semantic-release/exec", {
    "prepareCmd": "./update-version.sh ${nextRelease.version}",
   }],
  "@semantic-release/git"
],
"preset": "react"
}

Error I am getting

semantic-release
[4:55:45 AM] [semantic-release] › ℹ  Running semantic-release version 19.0.5
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/changelog"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[4:55:45 AM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[4:55:47 AM] [semantic-release] › ✖  An error occurred while running semantic-release: Error: Command failed with exit code 128: git tag --merged main
fatal: malformed object name main
    at makeError (/vercel/path0/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/vercel/path0/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getTags (/vercel/path0/node_modules/semantic-release/lib/git.js:31:11)
    at async /vercel/path0/node_modules/semantic-release/lib/branches/get-tags.js:18:9
    at async module.exports (/vercel/path0/node_modules/semantic-release/lib/branches/index.js:26:20)
    at async run (/vercel/path0/node_modules/semantic-release/index.js:65:22)
    at async module.exports (/vercel/path0/node_modules/semantic-release/index.js:269:22)
    at async module.exports (/vercel/path0/node_modules/semantic-release/cli.js:55:5) {
  shortMessage: 'Command failed with exit code 128: git tag --merged main',
  command: 'git tag --merged main',
  escapedCommand: 'git tag --merged main',
  exitCode: 128,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'fatal: malformed object name main',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}
Error: Command failed with exit code 128: git tag --merged main
fatal: malformed object name main
    at makeError (/vercel/path0/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/vercel/path0/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getTags (/vercel/path0/node_modules/semantic-release/lib/git.js:31:11)
    at async /vercel/path0/node_modules/semantic-release/lib/branches/get-tags.js:18:9
    at async module.exports (/vercel/path0/node_modules/semantic-release/lib/branches/index.js:26:20)
    at async run (/vercel/path0/node_modules/semantic-release/index.js:65:22)
    at async module.exports (/vercel/path0/node_modules/semantic-release/index.js:269:22)
    at async module.exports (/vercel/path0/node_modules/semantic-release/cli.js:55:5) {
  shortMessage: 'Command failed with exit code 128: git tag --merged main',
  command: 'git tag --merged main',
  escapedCommand: 'git tag --merged main',
  exitCode: 128,
  signal: undefined,
  signalDescription: undefined,
  stdout: '',
  stderr: 'fatal: malformed object name main',
  failed: true,
  timedOut: false,
  isCanceled: false,
  killed: false
}error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build-storybook && yarn run semantic-release" exited with 1

Is there anything I missed or left to configure. We can do that with Circleci or TravisCI any of this is necessary to do a semantic release?

SURTI ABHI
  • 64
  • 1
  • 5
  • This just means you don't have anything named `main`. For instance, your branch might be named `master`. (You did say your branch is named `main` but perhaps on the CI system you have *no* branches, which is also allowed in Git and is common on CI systems.) – torek Oct 08 '22 at 05:26
  • @torek main is my base branch. I also don't know whta's the exact issue – SURTI ABHI Oct 08 '22 at 11:30
  • CI pipelines often do not checkout or clone branches, but work with detached HEAD (i.e. with the commits directly). Maybe you first need to create the `main` branch in your CI's clone? – knittl Oct 08 '22 at 14:21
  • @knittl can you please more elaborate? – SURTI ABHI Oct 08 '22 at 15:31
  • Every repository clone has *its own* branches, independent of the branch names in the original (cloned) repository. CI systems, as @knittl and I said, may not bother with branches by default as their purpose tends to be to build one single commit. Consult the documentation for whatever CI/CD system you're using. – torek Oct 08 '22 at 16:16

0 Answers0