Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to release from Github actions #2567

Open
fawad-khalil-retailo opened this issue Sep 20, 2022 · 5 comments
Open

Not able to release from Github actions #2567

fawad-khalil-retailo opened this issue Sep 20, 2022 · 5 comments

Comments

@fawad-khalil-retailo
Copy link

fawad-khalil-retailo commented Sep 20, 2022

Current behavior

I am getting the following error:

git Error: Command failed with exit code 128: git rev-parse --git-dir
fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace

And

[10:04:20 PM] [semantic-release] › ✖  Failed step "fail" of plugin "@semantic-release/github"
[10:04:20 PM] [semantic-release] › ✖  An error occurred while running semantic-release: TypeError: Cannot read properties of undefined (reading 'name')

And

[10:04:20 PM] [semantic-release] › ✖  ENOGITREPO Not running from a git repository.
The semantic-release command must be executed from a Git repository.

The current working directory is /github/workspace.

Please verify your CI configuration to make sure the semantic-release command is executed from the root of the cloned repository.

AggregateError: 
    SemanticReleaseError: Not running from a git repository.

Expected behavior

It should release successfully.

semantic-release version

^17.4.2

CI environment

Github Actions

Plugins used

"plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/github",
    "@semantic-release/npm",
    [
      "@semantic-release/git",
      {
        "assets": ["package.json"],
        "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ]
  ]

semantic-release configuration

publish-gpr:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'

permissions:
  contents: write
  packages: write
  issues: write
  pull-requests: write
steps:
  - uses: actions/checkout@v3
  - uses: actions/setup-node@v3
    with:
      node-version: 16
  - name: Prepare env
    run: |
      {
        echo @development-team20:registry=https://npm.pkg.github.com/development-team20
        echo //npm.pkg.github.com/:_authToken=$GITHUB_TOKEN
        echo registry=https://registry.npmjs.org
      } | tee --append .npmrc
    env:
      GITHUB_TOKEN: ${{secrets.GL_NPM_TOKEN}}
  - run: |
      cat .npmrc
      ls
      pwd
      echo $GITHUB_WORKSPACE
      git config --global --add safe.directory $GITHUB_WORKSPACE
  - name: Install Dependencies
    uses: borales/[email protected]
    with:
      cmd: install
  - name: Compile
    uses: borales/[email protected]
    with:
      cmd: compile
  - name: Set ownership
    run: |
      # this is to fix GIT not liking owner of the checkout dir
      sudo chown -R $(id -u):$(id -g) $PWD
  - name: Semantic Release
    uses: borales/[email protected]
    with:
      cmd: semantic-release --debug
    env:
      GITHUB_TOKEN: ${{secrets.GL_NPM_TOKEN}}

CI logs

[9:53:44 PM] [semantic-release] › ℹ  Running semantic-release version 17.4.7
2022-09-20T21:53:44.274Z semantic-release:config load config from: /github/workspace/.releaserc.json
2022-09-20T21:53:44.279Z semantic-release:config options values: {
  branches: [ 'master' ],
  repositoryUrl: 'https://github.com/retailotech/react-native-ui-library.git',
  tagFormat: 'v${version}',
  plugins: [
    '@semantic-release/commit-analyzer',
    '@semantic-release/release-notes-generator',
    '@semantic-release/github',
    '@semantic-release/npm',
    [ '@semantic-release/git', [Object] ]
  ],
  _: [],
  debug: true,
  '$0': 'node_modules/.bin/semantic-release'
}
2022-09-20T21:53:44.504Z semantic-release:plugins options for @semantic-release/github/verifyConditions: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
2022-09-20T21:53:44.506Z semantic-release:plugins options for @semantic-release/npm/verifyConditions: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
2022-09-20T21:53:44.507Z semantic-release:plugins options for @semantic-release/git/verifyConditions: {
  assets: [ 'package.json' ],
  message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/git"
2022-09-20T21:53:44.508Z semantic-release:plugins options for @semantic-release/commit-analyzer/analyzeCommits: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
2022-09-20T21:53:44.508Z semantic-release:plugins options for @semantic-release/release-notes-generator/generateNotes: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
2022-09-20T21:53:44.509Z semantic-release:plugins options for @semantic-release/npm/prepare: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
2022-09-20T21:53:44.509Z semantic-release:plugins options for @semantic-release/git/prepare: {
  assets: [ 'package.json' ],
  message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
2022-09-20T21:53:44.5[10](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:11)Z semantic-release:plugins options for @semantic-release/github/publish: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/git"
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
2022-09-20T21:53:44.5[11](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:12)Z semantic-release:plugins options for @semantic-release/npm/publish: {}
2022-09-20T21:53:44.511Z semantic-release:plugins options for @semantic-release/github/addChannel: {}
2022-09-20T21:53:44.5[12](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:13)Z semantic-release:plugins options for @semantic-release/npm/addChannel: {}
2022-09-20T21:53:44.512Z semantic-release:plugins options for @semantic-release/github/success: {}
2022-09-20T21:53:44.512Z semantic-release:plugins options for @semantic-release/github/fail: {}
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[9:53:44 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
2022-09-20T21:53:44.534Z semantic-release:git Error: Command failed with exit code 128: git rev-parse --git-dir
fatal: detected dubious ownership in repository at '/github/workspace'
To add an exception for this directory, call:

	git config --global --add safe.directory /github/workspace
    at makeError (/github/workspace/node_modules/semantic-release/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/github/workspace/node_modules/semantic-release/node_modules/execa/index.js:118:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async isGitRepo (/github/workspace/node_modules/semantic-release/lib/git.js:190:[13](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:14))
    at async module.exports (/github/workspace/node_modules/semantic-release/lib/verify.js:[14](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:15):9)
    at async run (/github/workspace/node_modules/semantic-release/index.js:54:3)
    at async module.exports (/github/workspace/node_modules/semantic-release/index.js:260:22)
    at async module.exports (/github/workspace/node_modules/semantic-release/cli.js:55:5)
[9:53:44 PM] [semantic-release] › ℹ  Start step "fail" of plugin "@semantic-release/github"
[9:53:44 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication (https://api.github.com)
[9:53:44 PM] [semantic-release] › ✖  Failed step "fail" of plugin "@semantic-release/github"
[9:53:44 PM] [semantic-release] › ✖  An error occurred while running semantic-release: TypeError: Cannot read properties of undefined (reading 'name')
    at module.exports (/github/workspace/node_modules/semantic-release/node_modules/@semantic-release/github/lib/get-fail-comment.js:19:10)
    at module.exports (/github/workspace/node_modules/semantic-release/node_modules/@semantic-release/github/lib/fail.js:28:74)
    at async fail (/github/workspace/node_modules/semantic-release/node_modules/@semantic-release/github/index.js:64:3)
    at async validator (/github/workspace/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /github/workspace/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
    at async /github/workspace/node_modules/semantic-release/lib/plugins/pipeline.js:31:3
    at async Object.pluginsConf.<computed> [as fail] (/github/workspace/node_modules/semantic-release/lib/plugins/index.js:80:11)
    at async callFail (/github/workspace/node_modules/semantic-release/index.js:235:7)
    at async module.exports (/github/workspace/node_modules/semantic-release/index.js:264:7)
    at async module.exports (/github/workspace/node_modules/semantic-release/cli.js:55:5) {
  pluginName: '@semantic-release/github'
}
[9:53:44 PM] [semantic-release] › ✖  ENOGITREPO Not running from a git repository.
The semantic-release command must be executed from a Git repository.

The current working directory is /github/workspace.

Please verify your CI configuration to make sure the semantic-release command is executed from the root of the cloned repository.

AggregateError: 
    SemanticReleaseError: Not running from a git repository.
        at module.exports (/github/workspace/node_modules/semantic-release/lib/get-error.js:6:10)
        at module.exports (/github/workspace/node_modules/semantic-release/lib/verify.js:[15](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:16):[17](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:18))
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async run (/github/workspace/node_modules/semantic-release/index.js:54:3)
        at async module.exports (/github/workspace/node_modules/semantic-release/index.js:260:[22](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:23))
        at async module.exports (/github/workspace/node_modules/semantic-release/cli.js:55:5)
    at module.exports (/github/workspace/node_modules/semantic-release/lib/verify.js:41:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async run (/github/workspace/node_modules/semantic-release/index.js:54:3)
    at async module.exports (/github/workspace/node_modules/semantic-release/index.js:[26](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:27)0:22)
    at async module.exports (/github/workspace/node_modules/semantic-release/cli.js:[55](https://github.com/retailotech/react-native-ui-library/actions/runs/3093685286/jobs/5006338626#step:10:56):5)error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@JoshuaKGoldberg
Copy link
Contributor

I can repro this issue:

Interestingly, running the same npx semantic-release command locally in dry run mode gives a much more informative error message:

...
[12:26:23 PM] [semantic-release] › ✖  ERELEASEBRANCHES The release branches are invalid in the `branches` configuration.
A minimum of 1 and a maximum of 3 release branches are required in the branches configuration (https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches).

This may occur if your repository does not have a release branch, such as master.

Your configuration for the problematic branches is [].

AggregateError: 
    SemanticReleaseError: The release branches are invalid in the `branches` configuration.
        at module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/lib/get-error.js:6:10)
        at /Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/lib/branches/index.js:45:19
        at Array.reduce (<anonymous>)
        at module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/lib/branches/index.js:35:46)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at async run (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/index.js:65:22)
        at async module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/index.js:269:22)
        at async module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/cli.js:55:5)
    at module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/lib/branches/index.js:67:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async run (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/index.js:65:22)
    at async module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/index.js:269:22)
    at async module.exports (/Users/josh/repos/template-typescript-node-package/node_modules/semantic-release/cli.js:55:5)%                                                                   

https://github.com/semantic-release/semantic-release/blob/e516748/docs/usage/configuration.md#branches says branches should default to an array. Are the docs wrong, or is this error wrong?

@gr2m
Copy link
Member

gr2m commented Oct 1, 2022

I think the problem is that your default branch is main and that semantic release does not yet support main by default, we still didn't get to implement that 😢 I think that might be the cause, but if it is, the error message is not very helpful

@JoshuaKGoldberg
Copy link
Contributor

Oh, is there a tracking issue? I'd be happy to send that in. 🙂

@gr2m
Copy link
Member

gr2m commented Oct 1, 2022

It's not a straight forward fix, but it's a while since we investigated it. We are focusing on the ESM transition, any help with that would be much appreciated.

Here is the issue about supporting the main branch out of the box:
#1581

The ES Modules tracking issue is here:
#2133

@iwaduarte
Copy link

I have had this problem for the past 2 days. Trying to figure out what is going on.
And the problem is the nowhere in the documentation described.

Attention: Using main as a branch won't work.

The GitHub workflow would give the following message:

npm WARN exec The following package was not found and will be installed: [email protected]
Boilerplate {
  path: './boilerplates/site',
  contentPath: './boilerplates/site/content'
}

That would send me in a whole completely direction! That I couldn't find by searching on google. Look at these errors unaddressed and PR unattended I wonder: Is that repository going to be deprecated?

Additionally, sematic-release CLI is not working also. It breaks silently midway through configuration.

Shahroz16 added a commit to customerio/customerio-expo-plugin that referenced this issue Feb 27, 2023
sohamdev1 referenced this issue in distinction-dev/serverless-exports Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants