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

npm commands fail after performing no-ci release #1109

Closed
ZebraFlesh opened this issue Feb 27, 2019 · 3 comments
Closed

npm commands fail after performing no-ci release #1109

ZebraFlesh opened this issue Feb 27, 2019 · 3 comments

Comments

@ZebraFlesh
Copy link

ZebraFlesh commented Feb 27, 2019

Current behavior

  1. Perform a local release by executing an npm script. (dotenv is this package which is loading my tokens into my command environment.)
 "scripts": {
    "semantic-release": "dotenv semantic-release"
  },
  "release": {
    "ci": false,
    "dryRun": false,
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "@semantic-release/npm",
      "@semantic-release/github"
    ]
  },
  1. Release goes great!
  2. Prove it by executing npm view <my package> version
  3. Receive error Error: Failed to replace env in config: ${NPM_TOKEN}
  4. Notice that my .npmrc file is now modified. It has the line //artifactory.my-company.com/artifactory/api/npm/npm/:_authToken = ${NPM_TOKEN}

Expected behavior

npm commands successfully execute after performing a release; .npmrc file is unmodified

Environment

  • semantic-release version: ^15.13.3
  • CI environment: none -- running locally on Windows 10
  • Plugins used:
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    "@semantic-release/npm",
    "@semantic-release/github"
  • semantic-release configuration:
  "release": {
    "ci": false,
    "dryRun": false,
    "plugins": [
      "@semantic-release/commit-analyzer",
      "@semantic-release/release-notes-generator",
      "@semantic-release/changelog",
      "@semantic-release/npm",
      "@semantic-release/github"
    ]
  },
  • CI logs:
    Short version of logs that show same problem, but results in no release:
[9:04:27 AM] [semantic-release] » i  Running semantic-release version 15.13.3
[9:04:27 AM] [semantic-release] » √  Loaded plugin "verifyConditions" from "@semantic-release/changelog"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "verifyConditions" from "@semantic-release/github"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "prepare" from "@semantic-release/changelog"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "prepare" from "@semantic-release/npm"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "publish" from "@semantic-release/npm"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "publish" from "@semantic-release/github"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "success" from "@semantic-release/github"
[9:04:27 AM] [semantic-release] » √  Loaded plugin "fail" from "@semantic-release/github"
[9:04:28 AM] [semantic-release] » √  Run automated release from branch master
[9:04:30 AM] [semantic-release] » √  Allowed to push to the Git repository
[9:04:30 AM] [semantic-release] » i  Start step "verifyConditions" of plugin "@semantic-release/changelog"
[9:04:30 AM] [semantic-release] » √  Completed step "verifyConditions" of plugin "@semantic-release/changelog"
[9:04:30 AM] [semantic-release] » i  Start step "verifyConditions" of plugin "@semantic-release/npm"
[9:04:30 AM] [semantic-release] [@semantic-release/npm] » i  Verify authentication for registry http://artifactory.my-company.com/artifactory/api/npm/npm/
[9:04:30 AM] [semantic-release] [@semantic-release/npm] » i  Wrote NPM_TOKEN to C:\Users\nope\git\my-package\.npmrc
[9:04:30 AM] [semantic-release] » √  Completed step "verifyConditions" of plugin "@semantic-release/npm"
[9:04:30 AM] [semantic-release] » i  Start step "verifyConditions" of plugin "@semantic-release/github"
[9:04:30 AM] [semantic-release] [@semantic-release/github] » i  Verify GitHub authentication
[9:04:30 AM] [semantic-release] » √  Completed step "verifyConditions" of plugin "@semantic-release/github"
[9:04:31 AM] [semantic-release] » i  Found git tag v1.0.0 associated with version 1.0.0
[9:04:31 AM] [semantic-release] » i  Found 2 commits since last release
[9:04:31 AM] [semantic-release] » i  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:04:31 AM] [semantic-release] [@semantic-release/commit-analyzer] » i  Analyzing commit: docs: add missing step about enabling SSO for github token
[9:04:31 AM] [semantic-release] [@semantic-release/commit-analyzer] » i  The commit should not trigger a release
[9:04:31 AM] [semantic-release] [@semantic-release/commit-analyzer] » i  Analyzing commit: chore: perform release 1.0.0
[9:04:31 AM] [semantic-release] [@semantic-release/commit-analyzer] » i  The commit should not trigger a release
[9:04:31 AM] [semantic-release] [@semantic-release/commit-analyzer] » i  Analysis of 2 commits complete: no release
[9:04:31 AM] [semantic-release] » √  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[9:04:31 AM] [semantic-release] » i  There are no relevant changes, so no new version is released.
@pvdlg pvdlg added the support label Feb 27, 2019
@pvdlg
Copy link
Member

pvdlg commented Feb 27, 2019

In you reproduction steps you say the release works fine then you get Receive error Error: Failed to replace env in config: ${NPM_TOKEN}.
What command gave you the error? What's the problem exactly if the release works?

semantic-release is primarily meant to be used on a CI and adds the NPM_TOKEN from an environment variable to the .npmrc to be able to make releases. There is no other way to authenticate with npm, we can't change that.

@ZebraFlesh
Copy link
Author

  1. Release goes great!
  2. Prove it by executing npm view <my package> version
  3. Receive error Error: Failed to replace env in config: ${NPM_TOKEN}

As I indicated, the npm view command fails after the release completes. Indeed, all npm commands which must access a registry fail (install, whoami, etc). This is because sematic-release has left some cruft in my .npmrc file. I understand that modifying the .npmrc file is necessary. However, it seems reasonable that a run of semantic-release --no-ci would properly clean up after itself and not corrupt the environment.

@pvdlg
Copy link
Member

pvdlg commented Mar 6, 2019

Closing in favor of semantic-release/npm#145

@pvdlg pvdlg closed this as completed Mar 6, 2019
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

2 participants