Nicholas Devlin
Nicholas Devlin

Reputation: 31

Semantic-Release - pre-release version not incrementing for patch, minor or major version

Current behavior

This is a brand new project, so fresh versions etc.

Currently have a pre-release branch called "next", release branch called "stable", all features all worked on in our "development" branch and they have the correct feat(test): this is a test commit messages.

From the development branch we create a pull request into "next". Once we are happy with how it looks etc, we then merge our "development" branch into our "stable.

First push for "next" creates a tag called v1.0.0-next.1.

However, another feat commit doesnt increment the version to v1.1.0-next.1. It just creates v1.0.0-next.2.

If I then make a pull request for our "development" branch into our "stable" release branch, it updates the versions correct as it should, for example v1.1.0 gets released.

I have the following version set in my development branch package.json

"version": "0.0.0-next", Also my version is not being incremented in package.json as it did when I was running it locally, for any of the branches.

Expected behavior Expected behaviour would to have the pre-release version increment as per normal, also have my package.json update.

Package versions

semantic-release version: "@semantic-release": "^17.0.4", "@semantic-release/changelog": "^5.0.1", "@semantic-release/commit-analyzer": "^8.0.1", "@semantic-release/git": "^9.0.0", "@semantic-release/npm": "^7.0.5", "@semantic-release/release-notes-generator": "^9.0.1",

CI environment:

CircleCI

Plugins used:

{
"branches": ["stable", {name: "next", prerelease: true}],
"repositoryUrl": "https://x-token-auth:[email protected]/{user}/{repo}.git",
"ci": true,
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "./README.md",
}],
"@semantic-release/npm",
["@semantic-release/git", {
"assets": ["./README.md"],
}],
]
}

CI logs:


    !/bin/bash -eo pipefail
    npx semantic-release --debug
    [6:41:17 AM] [semantic-release] › ℹ Running semantic-release version 17.0.4
    semantic-release:config load config from: /home/circleci/project/.releaserc +0ms
    semantic-release:config options values: {
    semantic-release:config branches: [ 'stable', { name: 'next', prerelease: true } ],
    semantic-release:config repositoryUrl: 'https://x-token-auth: {BB-TOKEN} @bitbucket.org/repo/ui_kit.git',
    semantic-release:config tagFormat: 'v${version}',
    semantic-release:config plugins: [
    semantic-release:config '@semantic-release/commit-analyzer',
    semantic-release:config '@semantic-release/release-notes-generator',
    semantic-release:config [ '@semantic-release/changelog', [Object] ],
    semantic-release:config '@semantic-release/npm',
    semantic-release:config [ '@semantic-release/git', [Object] ]
    semantic-release:config ],
    semantic-release:config ci: true,
    semantic-release:config _: [],
    semantic-release:config debug: true,
    semantic-release:config '$0': 'node_modules/.bin/semantic-release'
    semantic-release:config } +1ms
    semantic-release:plugins options for @semantic-release/changelog/verifyConditions: { changelogFile: './README.md' } +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/changelog"
    semantic-release:plugins options for @semantic-release/npm/verifyConditions: {} +1ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/npm"
    semantic-release:plugins options for @semantic-release/git/verifyConditions: { assets: [ './README.md' ] } +1ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "verifyConditions" from "@semantic-release/git"
    semantic-release:plugins options for @semantic-release/commit-analyzer/analyzeCommits: {} +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "analyzeCommits" from "@semantic-release/commit-analyzer"
    semantic-release:plugins options for @semantic-release/release-notes-generator/generateNotes: {} +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "generateNotes" from "@semantic-release/release-notes-generator"
    semantic-release:plugins options for @semantic-release/changelog/prepare: { changelogFile: './README.md' } +1ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/changelog"
    semantic-release:plugins options for @semantic-release/npm/prepare: {} +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/npm"
    semantic-release:plugins options for @semantic-release/git/prepare: { assets: [ './README.md' ] } +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "prepare" from "@semantic-release/git"
    semantic-release:plugins options for @semantic-release/npm/publish: {} +0ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "publish" from "@semantic-release/npm"
    semantic-release:plugins options for @semantic-release/npm/addChannel: {} +1ms
    [6:41:17 AM] [semantic-release] › ✔ Loaded plugin "addChannel" from "@semantic-release/npm"
    semantic-release:get-tags found tags for branch stable: [] +0ms
    semantic-release:get-tags found tags for branch next: [ { gitTag: 'v1.0.0-next.1', version: '1.0.0-next.1', channels: [ 'next' ] } ] +12ms
    [6:41:20 AM] [semantic-release] › ✔ Run automated release from branch next on repository https://x-token-auth:{BB_TOKEN}@bitbucket.org/repol/ui_kit.git
    [6:41:20 AM] [semantic-release] › ✔ Allowed to push to the Git repository
    [6:41:20 AM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/changelog"
    [6:41:20 AM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/changelog"
    [6:41:20 AM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/npm"
    [6:41:20 AM] [semantic-release] [@semantic-release/npm] › ℹ Verify authentication for registry https://registry.npmjs.org/
    [6:41:20 AM] [semantic-release] [@semantic-release/npm] › ℹ Reading npm config from /home/circleci/project/.npmrc
    monarc
    [6:41:21 AM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/npm"
    [6:41:21 AM] [semantic-release] › ℹ Start step "verifyConditions" of plugin "@semantic-release/git"
    [6:41:21 AM] [semantic-release] › ✔ Completed step "verifyConditions" of plugin "@semantic-release/git"
    [6:41:21 AM] [semantic-release] › ℹ Found git tag v1.0.0-next.1 associated with version 1.0.0-next.1 on branch next
    semantic-release:get-commits Use from: 55f99bb238d96062ec73a9dadc2623a7afe8ad62 +0ms
    [6:41:21 AM] [semantic-release] › ℹ Found 2 commits since last release
    semantic-release:get-commits Parsed commits: [ { commit: { long: '27c780e14a70bc1558a4e68f795963b6886e45a1', short: '27c780e' }, tree: { long: 'c60fdbf8b833a81ec2b7985094eb6c89b910daa4', short: 'c60fdbf' }, author: { name: ', email: '', date: 2020-04-02T06:40:27.000Z }, committer: { name: 'Dev Ops', email: '', date: 2020-04-02T06:40:27.000Z }, subject: 'Merged in development (pull request #139)', body: 'feat(semver3): next #3\n', hash: '27c780e14a70bc1558a4e68f795963b6886e45a1', committerDate: 2020-04-02T06:40:27.000Z, message: 'Merged in development (pull request #139)\n\nfeat(semver3): next #3', gitTags: '(HEAD -> next, origin/next, master)' }, { commit: { long: '99f14f6759801f942a372000356da552f7427d78', short: '99f14f6' }, tree: { long: '5c6666840eec5cdfd21e8a2032933e7735544e30', short: '5c66668' }, author: { name:{name}, email: '', date: 2020-04-02T06:39:46.000Z }, committer: { name: {name}, email: ', date: 2020-04-02T06:39:46.000Z }, subject: 'feat(semver3): next #3', body: '', hash: '99f14f6759801f942a372000356da552f7427d78', committerDate: 2020-04-02T06:39:46.000Z, message: 'feat(semver3): next #3', gitTags: '(origin/development)' } ] +15ms
    [6:41:21 AM] [semantic-release] › ℹ Start step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
    [6:41:21 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: Merged in development (pull request #139)

    feat(semver3): next #3
    semantic-release:commit-analyzer Analyzing with default rules +0ms
    [6:41:21 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The commit should not trigger a release
    [6:41:21 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: feat(semver3): next #3
    semantic-release:commit-analyzer Analyzing with default rules +1ms
    semantic-release:commit-analyzer The rule { type: 'feat', release: 'minor' } match commit with release type 'minor' +0ms
    [6:41:21 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is minor
    [6:41:21 AM] [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analysis of 2 commits complete: minor release
    [6:41:21 AM] [semantic-release] › ✔ Completed step "analyzeCommits" of plugin "@semantic-release/commit-analyzer"
    [6:41:21 AM] [semantic-release] › ℹ The next release version is 1.0.0-next.2
    [6:41:21 AM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
    semantic-release:release-notes-generator version: '1.0.0-next.2' +0ms
    semantic-release:release-notes-generator host: undefined +0ms
    semantic-release:release-notes-generator owner: 'monarc_dev' +0ms
    semantic-release:release-notes-generator repository: 'ui_kit' +0ms
    semantic-release:release-notes-generator previousTag: 'v1.0.0-next.1' +0ms
    semantic-release:release-notes-generator currentTag: 'v1.0.0-next.2' +0ms
    semantic-release:release-notes-generator host: 'https://bitbucket.org' +0ms
    semantic-release:release-notes-generator linkReferences: undefined +0ms
    semantic-release:release-notes-generator issue: 'issue' +0ms
    semantic-release:release-notes-generator commit: 'commits' +0ms
    [6:41:21 AM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
    [6:41:21 AM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/changelog"
    [6:41:21 AM] [semantic-release] [@semantic-release/changelog] › ℹ Update /home/circleci/project/README.md
    [6:41:21 AM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/changelog"
    [6:41:21 AM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/npm"
    [6:41:21 AM] [semantic-release] [@semantic-release/npm] › ℹ Write version 1.0.0-next.2 to package.json in /home/circleci/project
    v1.0.0-next.2
    [6:41:21 AM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/npm"
    [6:41:21 AM] [semantic-release] › ℹ Start step "prepare" of plugin "@semantic-release/git"
    [6:41:22 AM] [semantic-release] [@semantic-release/git] › ℹ Found 1 file(s) to commit
    semantic-release:git add file to git index {
    command: 'git add --force --ignore-errors README.md',
    exitCode: 0,
    stdout: '',
    stderr: '',
    all: undefined,
    failed: false,
    timedOut: false,
    isCanceled: false,
    killed: false
    } +0ms
    semantic-release:git commited files: [ 'README.md' ] +0ms
    [6:41:23 AM] [semantic-release] [@semantic-release/git] › ℹ Prepared Git release: v1.0.0-next.2
    [6:41:23 AM] [semantic-release] › ✔ Completed step "prepare" of plugin "@semantic-release/git"
    [6:41:23 AM] [semantic-release] › ℹ Start step "generateNotes" of plugin "@semantic-release/release-notes-generator"
    semantic-release:release-notes-generator version: '1.0.0-next.2' +2s
    semantic-release:release-notes-generator host: undefined +0ms
    semantic-release:release-notes-generator owner: 'monarc_dev' +0ms
    semantic-release:release-notes-generator repository: 'ui_kit' +0ms
    semantic-release:release-notes-generator previousTag: 'v1.0.0-next.1' +0ms
    semantic-release:release-notes-generator currentTag: 'v1.0.0-next.2' +1ms
    semantic-release:release-notes-generator host: 'https://bitbucket.org' +0ms
    semantic-release:release-notes-generator linkReferences: undefined +0ms
    semantic-release:release-notes-generator issue: 'issue' +0ms
    semantic-release:release-notes-generator commit: 'commits' +0ms
    [6:41:23 AM] [semantic-release] › ✔ Completed step "generateNotes" of plugin "@semantic-release/release-notes-generator"
    [6:41:25 AM] [semantic-release] › ✔ Created tag v1.0.0-next.2
    [6:41:25 AM] [semantic-release] › ℹ Start step "publish" of plugin "@semantic-release/npm"
    [6:41:25 AM] [semantic-release] [@semantic-release/npm] › ℹ Publishing version 1.0.0-next.2 to npm registry on dist-tag next
    npm notice
    npm notice package @monarc-dev/[email protected]
    npm notice === Tarball Contents ===
    npm notice 3.0kB package.json
    npm notice 8.8kB README.md
    npm notice === Tarball Details ===
    npm notice name: @monarc-dev/react-toolkit
    npm notice version: 1.0.0-next.2
    npm notice package size: 3.0 kB
    npm notice unpacked size: 11.8 kB
    npm notice shasum: 3abdccb17e58f8e116ffe1dcc6d6271592e4390c
    npm notice integrity: sha512-GOjVWbDMbPyTr[...]KoK2fsQsoPUHg==
    npm notice total files: 2
    npm notice

    @monarc-dev/[email protected]
    [6:41:28 AM] [semantic-release] [@semantic-release/npm] › ℹ Published @monarc-dev/[email protected] to dist-tag @next on https://registry.npmjs.org/
    [6:41:28 AM] [semantic-release] › ✔ Completed step "publish" of plugin "@semantic-release/npm"
    [6:41:28 AM] [semantic-release] › ✔ Published release 1.0.0-next.2 on next channel

Things I've tried:

Adding these options and running locally.

`ci: false`

`dryRun: true`

Ran npx semantic-release locally on my computer while have the beta branch checked out after having a commit that would increment the version. Still same issue, debug logs report a major version increase for example but still stays to the same 1.0.0-next.x, in this case should be 2.0.0-next.x.

If anyone could assist that would be greatly appreciated :)

Upvotes: 3

Views: 5246

Answers (1)

Matt Strom
Matt Strom

Reputation: 615

I had been encountering the same behavior and went spelunking into the source of semantic-release.

At v17.0.3 semantic-release switched to using Git notes to store information about which releases happened in which branch. However, a force push will overwrite Git notes. Manually adding notes back did the trick for me.

They have instructions for adding notes in their troubleshooting doc here:

https://github.com/semantic-release/semantic-release/blob/master/docs/support/troubleshooting.md#release-not-found-release-branch-after-git-push---force

Upvotes: 2

Related Questions