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

package.json version not updated, despite correct plugin ordering #615

Closed
jimbojw opened this issue May 13, 2023 · 1 comment
Closed

package.json version not updated, despite correct plugin ordering #615

jimbojw opened this issue May 13, 2023 · 1 comment

Comments

@jimbojw
Copy link

jimbojw commented May 13, 2023

I have semantic-release installed and configured to run in GitHub Actions. It runs, successfully updating the CHANGELOG.md and including the dist/ distributables in the automated git commit. It also successfully pushes the artifacts up to npm.

However, it does not update the version field of the package.json file.

Recent example:

I have read semantic-release/semantic-release#1593, which reports the same problem. In that issue's discussion, people report that moving the @semantic-release/npm entry before the @semantic-release/git entry in the config fixes the issue. However, this has not worked for me.

Here is my .releaserc file content:

{
  "branches": [
    "main"
  ],
  "plugins": [
    [
      "@semantic-release/commit-analyzer"
    ],
    [
      "@semantic-release/release-notes-generator"
    ],
    [
      "@semantic-release/changelog",
      {
        "changelogFile": "CHANGELOG.md"
      }
    ],
    [
      "@semantic-release/npm"
    ],
    [
      "@semantic-release/git",
      {
        "assets": [
          "CHANGELOG.md",
          "dist/**"
        ],
        "message": "chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],
    [
      "@semantic-release/github"
    ]
  ]
}

What must I do to configure @semantic-release/npm to update the version field of package.json?

@jimbojw
Copy link
Author

jimbojw commented May 15, 2023

Update: The issue is NOT with this package (@semantic-release/npm) but rather with the configuration of @semantic-release/git.

Root cause: @semantic-release/git will only include those files specifically listed in its assets glob list. This means that even though @semantic-release/npm may be updating your package.json file, you must also list it under @semantic-release/git assets for it to be committed.

Example:

    [
      "@semantic-release/npm"
    ],
    [
      "@semantic-release/git",
      {
        "assets": [
          "CHANGELOG.md",
          "dist/**",
          "package.json",  <--- ADD THIS LINE
        ],
        "message": "chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
      }
    ],

@jimbojw jimbojw closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
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

1 participant