git icon indicating copy to clipboard operation
git copied to clipboard

Adding package.json to git assets does not result in the file being pushed back to repo

Open james-kontralto opened this issue 4 years ago • 6 comments

Current behavior

The following configuration results in the changelog being pushed back to the target branch, but not package.json.

prepare:
  - path: '@semantic-release/changelog'
  - path: '@semantic-release/git'
    message: 'RELEASE: ${nextRelease.version}'
    assets: ['CHANGELOG.md', 'package.json']

The CI logs indicate the new version is being written to package.json, and I'm hoping to get that pushed back upstream so the version shown in the repo is correct.

Expected behavior

package.json should be pushed to the repo along with CHANGELOG.md.

Environment

  • semantic-release version: 18.0.1
  • CI environment: GitLab CI
  • Plugins used: changelog, commit-analyzer, exec, git, gitlab, npm, release-notes-generator
  • semantic-release configuration: https://gitlab.com/james-kontralto/semantic-release-test/-/blob/main/.releaserc.yml
  • CI logs: https://gitlab.com/james-kontralto/semantic-release-test/-/jobs/1905701383

Also check out the release commit, it has CHANGELOG.md changes but not package.json: https://gitlab.com/james-kontralto/semantic-release-test/-/commit/fcfe8f8311ff5443ecb4b7bd2bc9f37a7fb0e80b

james-kontralto avatar Dec 21 '21 00:12 james-kontralto

I still have to verify if the package.json is the reason nothing gets pushed but I'm experiencing the same issue in a new repo right now.

manuelbieh avatar Jan 25 '22 02:01 manuelbieh

Same issue on my @tinesoft/nxrocks repo, with that semantic-release config 😞...

Any update?

tinesoft avatar Feb 14 '22 11:02 tinesoft

I was experiencing the same problem and apparently moving "@semantic-release/git" to the end of the list of plugins (and specially after @semantic-release/npm) fixed the problem. Not sure if it's the same problem but maybe it could help someone reading this.

andsouto avatar Feb 14 '22 19:02 andsouto

Hi again,

Never mind, I figured it out: in my case, not all the files listed in the assets option of the plugin, were actually modified (and so "visible") to @semantic-release/git. In fact, I was NPM publishing from a custom dist/<package> folder (@semantic-release/npm phase), and only changes to the changelog.md were copied back to the root folder for the next phase.

tinesoft avatar Feb 16 '22 20:02 tinesoft

I'm experiencing this issue as well. The version field is updated in package.json but the plugin never commits and pushes to the Github repo.

Here's the order of my plugins (git is at the end of the list and after npm):

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

Here's the output of running npx semantic-release --no-ci

[1:39:58 PM] [semantic-release] › ℹ  Running semantic-release version 18.0.1
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/npm"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "verifyConditions" from "@semantic-release/github"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "prepare" from "@semantic-release/npm"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/npm"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "publish" from "@semantic-release/github"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/npm"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "addChannel" from "@semantic-release/github"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "success" from "@semantic-release/github"
[1:39:58 PM] [semantic-release] › ✔  Loaded plugin "fail" from "@semantic-release/github"
[1:40:00 PM] [semantic-release] › ✔  Run automated release from branch release-candidates on repository [email protected]:alexandert/fs-apt-ui.git
[1:40:01 PM] [semantic-release] › ✔  Allowed to push to the Git repository
[1:40:01 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/npm"
[1:40:01 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/npm"
[1:40:01 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/github"
[1:40:01 PM] [semantic-release] [@semantic-release/github] › ℹ  Verify GitHub authentication (https://github.com/api/v3)
[1:40:01 PM] [semantic-release] › ✔  Completed step "verifyConditions" of plugin "@semantic-release/github"
[1:40:01 PM] [semantic-release] › ℹ  Found git tag 2.0.0-rc.22 associated with version 2.0.0-rc.22 on branch release-candidates
[1:40:01 PM] [semantic-release] › ℹ  Found 1 commits since last release
[1:40:01 PM] [semantic-release] › ℹ  Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:40:01 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analyzing commit: feat: remove
[1:40:01 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  The release type for the commit is minor
[1:40:01 PM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ  Analysis of 1 commits complete: minor release
[1:40:01 PM] [semantic-release] › ✔  Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
[1:40:01 PM] [semantic-release] › ℹ  The next release version is 2.0.0-rc.23
[1:40:01 PM] [semantic-release] › ℹ  Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:40:01 PM] [semantic-release] › ✔  Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
[1:40:01 PM] [semantic-release] › ℹ  Start step "prepare" of plugin "@semantic-release/npm"
[1:40:01 PM] [semantic-release] [@semantic-release/npm] › ℹ  Write version 2.0.0-rc.23 to package.json in /home/alexandert/alex/fs-apt-ui
v2.0.0-rc.23
[1:40:01 PM] [semantic-release] › ✔  Completed step "prepare" of plugin "@semantic-release/npm"
[1:40:09 PM] [semantic-release] › ✔  Created tag 2.0.0-rc.23
[1:40:09 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/npm"
[1:40:09 PM] [semantic-release] [@semantic-release/npm] › ℹ  Skip publishing to npm registry as package.json's private property is true
[1:40:09 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/npm"
[1:40:09 PM] [semantic-release] › ℹ  Start step "publish" of plugin "@semantic-release/github"
[1:40:09 PM] [semantic-release] [@semantic-release/github] › ℹ  Published GitHub release: https://github.com/alexandert/fs-apt-ui/releases/tag/2.0.0-rc.23
[1:40:09 PM] [semantic-release] › ✔  Completed step "publish" of plugin "@semantic-release/github"
[1:40:09 PM] [semantic-release] › ℹ  Start step "success" of plugin "@semantic-release/github"
[1:40:11 PM] [semantic-release] › ✔  Completed step "success" of plugin "@semantic-release/github"
[1:40:11 PM] [semantic-release] › ✔  Published release 2.0.0-rc.23 on release-candidates channel

alexthaii avatar Apr 18 '22 17:04 alexthaii

I ran into this today, but it turned out to be my mistake. If you don't see Loaded plugin "verifyConditions" from "@semantic-release/git" in your logs, there might be something wrong with your configuration that's preventing the git plugin from being loaded at all!

In my case, I had "release": { "branches": ["main"] } in my package.json and all the rest of my semantic-release configuration in release.config.js. That's not supported! I think what it did was add that branches setting to the default configuration, and it ignored my release.config.js entirely.

It took me a while to figure this out because the default configuration is so similar to the configuration I wanted. The main difference is that the default config didn't use the git plugin!

cwillisf avatar May 21 '22 01:05 cwillisf