semantic-release / npm

:ship: semantic-release plugin to publish a npm package
MIT License
242 stars 114 forks source link

pkgRoot property not working #601

Open paulorenanmelo opened 1 year ago

paulorenanmelo commented 1 year ago

Hi, I'm having an error using Semantic Release, which seems to indicate that the pkgRoot variable is not being picked up:

npm ERR! code ENOENT npm ERR! syscall open npm ERR! path /builds/squint-nyc/bootstrap-in-a-snap/package.json npm ERR! errno -2 npm ERR! enoent ENOENT: no such file or directory, open '/builds/squint-nyc/bootstrap-in-a-snap/package.json' npm ERR! enoent This is related to npm not being able to find a file.

My folder structure (relative to /builds/squint-nyc/bootstrap-in-a-snap/) is as follows:

.releaserc.json .gitlab-ci.yml Packages/com.squintopera.unity.bootstrap/package.json

And here is my releaserc.json. Am I doing something wrong, or is it a bug in SemanticRelease?

{
  "branch": "master",
  "tagFormat": "v${version}",
  "plugins": [
    ["@semantic-release/commit-analyzer", { 
      "preset": "angular" 
    }],
    "@semantic-release/release-notes-generator",
    ["@semantic-release/npm", { 
      "npmPublish": true,
      "pkgRoot": "./Packages/com.squintopera.unity.bootstrap"
    }],
    ["@semantic-release/changelog", { 
      "preset": "angular",
      "changelogFile": "CHANGELOG.md"
    }],
    ["@semantic-release/git", {
      "assets": [
        "package.json",
        "README.md",
        "CHANGELOG.md",
        "Packages/com.squintopera.unity.bootstrap/**/*.*"
      ],
      "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
    }],
    "@semantic-release/gitlab"
  ]
}

And here is my gitlab-ci.yml

image: node:18.7.0-buster-slim

stages:
  - release

variables:
  GIT_STRATEGY: fetch
  GIT_SUBMODULE_STRATEGY: recursive
  GIT_DEPTH: "0"
  GITLAB_TOKEN: $CI_API_TOKEN
  PKG_ROOT: Packages/com.squintopera.unity.bootstrap

package:
  stage: release
  only:
    - master
  before_script:
    - apt-get update && apt-get install -y --no-install-recommends git-core git-lfs ca-certificates
    - npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/gitlab
  script:
    - git lfs pull
    - | # Rename Samples to Samples~ for packaging
      if [[ -d "$PKG_ROOT/Samples" ]]; then
        mv $PKG_ROOT/Samples $PKG_ROOT/Samples~
        rm -f $PKG_ROOT/Samples.meta
      fi
    - | # Run semantic-release to generate changelog, bump version number, and push package
      npm config set com.squintopera.unity:registry ${NPM_REGISTRY_URL}
      npm config set '${NPM_REGISTRY_AUTH}' "${NPM_REGISTRY_TOKEN}"
      export NPM_TOKEN=${NPM_REGISTRY_TOKEN}
      npm run semantic-release
jedwards1211 commented 4 months ago

dupe of #504