0

I have an NPM package I am trying to set up semantic release for so it will automatically deploy with a version bump.

I recently migrated from an old repo / npm package to a new one and since doing so semantic version wont create a new release for me and just says:

The local branch main is behind the remote one, therefore a new version won't be published.

I have created the v1.0.0 tag in the new repo and that matches the only published version of the package so far.

I have removed the changelog.md so it should start fresh.

My release config is like so:

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

It's a public package so you can see the CI for yourself: https://github.com/stretch0/use-feature/actions/runs/3862807130/jobs/6584602017

Repo is here if you'd like to see the rest of the code: https://github.com/stretch0/use-feature

Stretch0
  • 8,362
  • 13
  • 71
  • 133

1 Answers1

0

You can check the tags on the remote:

git ls-remote --tags origin

Then on your local repo:

git tag

1- To fetch all tags from the remote:

git fetch --tags

2- To push tags to the remote

git push --follow-tags

Step 1 should be enough. If it's not, step 2 may help. If it's not, run these 2 steps from your runner directory against the generated repository (i.e. actions-runner/_work/{reponame}/).

  • Do you mean I should be running `git ls-remote --tags origin` inside my CI publish.yml action? – Stretch0 Jan 07 '23 at 18:48
  • No. Steps 1 and 2 in my example should be run within your repository (The directory that contains the .git folder) – Patrice Thimothee Jan 07 '23 at 18:54
  • I might be missing something here but I have run them locally and it seems to have pulled down the tag and then I have run them within my CI and I'm still getting the same issue where no new version is created which appears to be because of the warning: `The local branch main is behind the remote one, therefore a new version won't be published.` - https://github.com/stretch0/use-feature/actions/runs/3863465733/jobs/6585672726 – Stretch0 Jan 07 '23 at 18:59
  • Unfortunately, it's because Semantic-Release syncs against your CI, not the local folder. If you can locate the folder your CI runner uses, run these commands directly there. – Patrice Thimothee Jan 07 '23 at 19:04
  • Doesn't running those commands in my CI do exactly that? – Stretch0 Jan 07 '23 at 19:07
  • When you say your CI, do you mean the CI runner? It should be the folder the runner uses. I use Semantic-Release on some of my projects. For instance, here: https://github.com/thimpat/to-esm – Patrice Thimothee Jan 07 '23 at 19:12
  • When I say CI I mean in my GitHub action here - https://github.com/stretch0/use-feature/actions/runs/3863465733/jobs/6585672726 – Stretch0 Jan 07 '23 at 19:15
  • In your checkout process, I can see that your runner uses that folder: /home/runner/work/use-feature/use-feature Now, I am unsure whether you use a Docker image. In this case, try to add this command ```git fetch --tags``` inside your Github action.yml and do a push. My runner runs from inside a VM, so the process is different for me as I can directly access the CI directory. – Patrice Thimothee Jan 07 '23 at 19:25
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/250931/discussion-between-patrice-thimothee-and-stretch0). – Patrice Thimothee Jan 07 '23 at 19:30