Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork546
Description
Context
Hello, and thank you for the great tool!
We had an issue when making releases with commits that aren't the latest one in the release branch. We use a Github-like flow with a main branch and feature branches that merge into it. We don't consider every commit on the main branch to be production-ready so we use manual triggers in the main branch's pipelines to optionally make a release or a prerelease (with the channelrc). We use conventional-changelog to infer the version from the commit history and create gitlab releases with changelogs.
Problem
If the main branch has advanced and we try to run release-it on a previous commit in the same branch, the newly created tag points to the latest commit of main instead of the one used to trigger the pipeline.
Expected Behavior
When running release-it on a commit, that commit is treated as the latest of the branch and the releases created points to that commit and not the latest.
Notes
- This issue happened while the pipeline had the current commit as the latest (clean pipeline, commits ahead were not pulled)
- We tested changing
GIT_DEPTHandGIT_STRATEGYbut that did not work - If we use release-it without prior processing (checking out to the
CI_COMMIT_REF_NAME) we get:fatal: ref HEAD is not a symbolic ref - Checking out a temporary branch in the CI and setting
no-git.requireUpstreamhelped to use the correct commit but the process crashed during the gitlab release (preparation?) step which ended up failing the whole release and the tag was not created.
Error log
RELEASE-IT:GITLAB 216: Error at GitLab.request (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:197:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async GitLab.createRelease (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:249:20) at async GitLab.release (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:156:14) at async runLifeCycleHook (file:///usr/local/lib/node_modules/release-it/lib/index.js:45:28) at async runTasks (file:///usr/local/lib/node_modules/release-it/lib/index.js:126:11)RELEASE-IT:GITLAB 216: Error at GitLab.request (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:197:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async GitLab.createRelease (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:249:20) at async GitLab.release (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:156:14) at async runLifeCycleHook (file:///usr/local/lib/node_modules/release-it/lib/index.js:45:28) at async runTasks (file:///usr/local/lib/node_modules/release-it/lib/index.js:126:11)ERROR Error at GitLab.request (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:197:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async GitLab.createRelease (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:249:20) at async GitLab.release (file:///usr/local/lib/node_modules/release-it/lib/plugin/gitlab/GitLab.js:156:14) at async runLifeCycleHook (file:///usr/local/lib/node_modules/release-it/lib/index.js:45:28) at async runTasks (file:///usr/local/lib/node_modules/release-it/lib/index.js:126:11)Example
These logs show an example run. We have the following commits
- feat: 2 (d0bd831266a0dae79b24db4c0b6e7f63b5fc87d2) -> latest commit in main
- feat: 1 (1991cf2a472657f47db987a1199d7981128a6415) -> commit on which the pipeline is executed
Pipeline Job:
release-rc:image:node:20variables:RELEASE_IT_CONFIG:|- { "$schema": "https://unpkg.com/release-it@18/schema/release-it.json", "git": { "tag": true, "push": false, "commit": false, "tagMatch": "v*", "requireCommits": true, "requireCommitsFail": false, "requireCleanWorkingDir":false }, "npm": { "publish": false, "ignoreVersion":true }, "gitlab": { "release": true, "tokenRef": "CI_JOB_TOKEN", "tokenHeader": "Job-Token", "skipChecks":true }, "plugins": { "@release-it/conventional-changelog": { "preset": "angular" } } }GIT_DEPTH:0before_script: -npm install -g release-it @release-it/conventional-changelog -git config --global user.email "ci@example.com" -git config --global user.name "CI User" -'[ -f ".release-it.json" ] || echo $RELEASE_IT_CONFIG > .release-it.json'stage:releasescript: -git log -n 5 -git rev-parse --abbrev-ref HEAD -NODE_DEBUG=release-it:* release-it -VV --ci --no-git.requireUpstream --preRelease rc -git log -n 5 -git rev-parse --abbrev-ref HEADrules: -if:"$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"when:manual
Pipeline logs of `feat: 1` with some git commands to help debug
$ git rev-parse HEAD1991cf2a472657f47db987a1199d7981128a6415$ git log -n 5commit 1991cf2a472657f47db987a1199d7981128a6415Author: MeDate: Mon Apr 7 16:02:02 2025 -0400 feat: 1commit 4fa2d81028a9d19416b25484351d9fe6357fabf9Author: MeDate: Mon Apr 7 15:53:34 2025 -0400 feat: no-released yetcommit 1d46a0824dfde48003a166aa7fe792b7da66e341Author: MeDate: Mon Apr 7 15:53:23 2025 -0400 fix: intermediatecommit 5b38c9cdd387d7506bb00de390c59965e2ed2a83Author: MeDate: Mon Apr 7 15:53:09 2025 -0400 feat: releasedcommit b02333f8464ca8ffef02dcd3422f5fb46c937fceAuthor: MeDate: Mon Apr 7 15:31:02 2025 -0400 feat: another debug$ git rev-parse --abbrev-ref HEADHEAD$ NODE_DEBUG=release-it:* release-it -VV --ci --no-git.requireUpstream --preRelease rcRELEASE-IT:CONFIG 212: { cosmiconfig: { config: { '': 'https://unpkg.com/release-it@18/schema/release-it.json', git: [Object], npm: [Object], gitlab: [Object], plugins: [Object] }, filepath: '/builds/my-repo/repo/.release-it.json' }}RELEASE-IT:CONFIG 212: { system: { 'release-it': '18.1.2', node: 'v20.19.0', os: 'Linux 6.6' }}RELEASE-IT:CONFIG 212: { _: [], verbose: 2, ci: true, git: { requireUpstream: false, tag: true, push: false, commit: false, tagMatch: 'v*', requireCommits: true, requireCommitsFail: false, requireCleanWorkingDir: false, changelog: 'git log --pretty=format:"* %s (%h)" ${from}...${to}', requireBranch: false, commitsPath: '', addUntrackedFiles: false, commitMessage: 'Release ${version}', commitArgs: [], tagExclude: null, tagName: null, getLatestTagFromAllRefs: false, tagAnnotation: 'Release ${version}', tagArgs: [], pushArgs: [ '--follow-tags' ], pushRepo: '' }, preRelease: 'rc', increment: undefined, '': 'https://unpkg.com/release-it@18/schema/release-it.json', npm: { publish: false, ignoreVersion: true, publishPath: '.', publishArgs: [], tag: null, otp: null, allowSameVersion: false, versionArgs: [], skipChecks: false, timeout: 10 }, gitlab: { release: true, tokenRef: 'CI_JOB_TOKEN', tokenHeader: 'Job-Token', skipChecks: true, releaseName: 'Release ${version}', releaseNotes: null, milestones: [], certificateAuthorityFile: null, secure: null, assets: null, useIdsForUrls: false, useGenericPackageRepositoryForAssets: false, genericPackageRepositoryName: 'release-it', origin: null }, plugins: { '@release-it/conventional-changelog': { preset: 'angular' } }, hooks: {}, github: { release: false, releaseName: 'Release ${version}', releaseNotes: null, autoGenerate: false, preRelease: false, draft: false, tokenRef: 'GITHUB_TOKEN', assets: null, host: null, timeout: 0, proxy: null, skipChecks: false, web: false, comments: { submit: false, issue: ':rocket: _This issue has been resolved in v${version}. See [${releaseName}](${releaseUrl}) for release notes._', pr: ':rocket: _This pull request is included in v${version}. See [${releaseName}](${releaseUrl}) for release notes._' } }, version: { increment: undefined, isPreRelease: true, preReleaseId: 'rc', preReleaseBase: undefined }}RELEASE-IT:CONFIG 212: { '@release-it/conventional-changelog': { preset: 'angular' } }RELEASE-IT:PLUGINS 212: { namespace: '@release-it/conventional-changelog', options: { preset: 'angular', tagPrefix: '' }}RELEASE-IT:PLUGINS 212: { namespace: 'npm', options: { publish: false, ignoreVersion: true, publishPath: '.', publishArgs: [], tag: null, otp: null, allowSameVersion: false, versionArgs: [], skipChecks: false, timeout: 10 }}RELEASE-IT:PLUGINS 212: { namespace: 'gitlab', options: { release: true, tokenRef: 'CI_JOB_TOKEN', tokenHeader: 'Job-Token', skipChecks: true, releaseName: 'Release ${version}', releaseNotes: null, milestones: [], certificateAuthorityFile: null, secure: null, assets: null, useIdsForUrls: false, useGenericPackageRepositoryForAssets: false, genericPackageRepositoryName: 'release-it', origin: null, tagExclude: null, tagName: null, tagMatch: 'v*', getLatestTagFromAllRefs: false, pushRepo: '', changelog: 'git log --pretty=format:"* %s (%h)" ${from}...${to}', commit: false }}RELEASE-IT:PLUGINS 212: { namespace: 'git', options: { requireUpstream: false, tag: true, push: false, commit: false, tagMatch: 'v*', requireCommits: true, requireCommitsFail: false, requireCleanWorkingDir: false, changelog: 'git log --pretty=format:"* %s (%h)" ${from}...${to}', requireBranch: false, commitsPath: '', addUntrackedFiles: false, commitMessage: 'Release ${version}', commitArgs: [], tagExclude: null, tagName: null, getLatestTagFromAllRefs: false, tagAnnotation: 'Release ${version}', tagArgs: [], pushArgs: [ '--follow-tags' ], pushRepo: '' }}RELEASE-IT:CONFIG 212: { npm: { name: 'ci-test-service' } }$ git rev-parse --abbrev-ref HEADHEADHEADRELEASE-IT:SHELL 212: { command: 'git rev-parse --abbrev-ref HEAD', options: { write: false }, code: 0, stdout: 'HEAD', stderr: ''}$ git config --get branch.HEAD.remoteRELEASE-IT:SHELL 212: { command: 'git config --get branch.HEAD.remote', options: { write: false }, code: 1, stdout: '', stderr: ''}$ git remote get-url originhttps://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.githttps://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.gitRELEASE-IT:SHELL 212: { command: 'git remote get-url origin', options: { write: false }, code: 0, stdout: 'https://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.git', stderr: ''}$ git fetchRELEASE-IT:SHELL 212: { command: 'git fetch', options: {}, code: 0, stdout: '', stderr: '' }$ git rev-parse --abbrev-ref HEAD [cached]RELEASE-IT:CONFIG 212: { remoteUrl: 'https://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.git', branchName: 'HEAD', repo: { host: 'gitlab.com', owner: 'my-repo/infra', project: 'repo', protocol: 'https', remote: 'https://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.git', repository: 'my-repo/repo' }}$ git describe --tags --match=v* --abbrev=0v0.7.0-rc.2v0.7.0-rc.2RELEASE-IT:SHELL 212: { command: 'git describe --tags --match=v* --abbrev=0', options: { write: false }, code: 0, stdout: 'v0.7.0-rc.2', stderr: ''}RELEASE-IT:CONFIG 212: { latestTag: 'v0.7.0-rc.2', secondLatestTag: null, tagTemplate: 'v${version}'}$ git describe --tags --match=v* --abbrev=0 [cached]$ git rev-list v0.7.0-rc.2..HEAD --count44RELEASE-IT:SHELL 212: { command: 'git rev-list v0.7.0-rc.2..HEAD --count ', options: { write: false }, code: 0, stdout: '4', stderr: ''}$ git rev-parse --abbrev-ref HEAD [cached]$ git config --get branch.HEAD.remote [cached]$ git remote get-url origin [cached]$ git fetch [cached]$ git rev-parse --abbrev-ref HEAD [cached]RELEASE-IT:CONFIG 212: { remoteUrl: 'https://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.git', branchName: 'HEAD', repo: { host: 'gitlab.com', owner: 'my-repo/infra', project: 'repo', protocol: 'https', remote: 'https://gitlab-ci-token:[MASKED]@gitlab.com/my-repo/repo.git', repository: 'my-repo/repo' }}$ git describe --tags --match=v* --abbrev=0 [cached]RELEASE-IT:CONFIG 212: { latestTag: 'v0.7.0-rc.2', secondLatestTag: null, tagTemplate: 'v${version}'}RELEASE-IT:@RELEASE-IT/CONVENTIONAL-CHANGELOG 212: { increment: undefined, latestVersion: '0.7.0-rc.2', isPreRelease: true, preReleaseId: 'rc'}RELEASE-IT:@RELEASE-IT/CONVENTIONAL-CHANGELOG 212: conventionalRecommendedBump { options: { preset: 'angular', tagPrefix: '' } }RELEASE-IT:@RELEASE-IT/CONVENTIONAL-CHANGELOG 212: { result: { level: 1, reason: 'There are 0 BREAKING CHANGES and 3 features', releaseType: 'minor' }}RELEASE-IT:@RELEASE-IT/CONVENTIONAL-CHANGELOG 212: conventionalChangelog { options: { releaseCount: 1, preset: 'angular', tagPrefix: '' }, context: { version: '0.7.0-rc.3', previousTag: 'v0.7.0-rc.2', currentTag: 'v0.7.0-rc.3' }, gitRawCommitsOpts: { debug: [Function: logger] { enabled: [Getter] }, from: 'v0.7.0-rc.2' }, parserOpts: undefined, writerOpts: undefined}RELEASE-IT:@RELEASE-IT/CONVENTIONAL-CHANGELOG 212: Your git-log command is:git log --format=%B%n-hash-%n%H%n-gitTags-%n%d%n-committerDate-%n%ci%n------------------------ >8 ------------------------ v0.7.0-rc.2..HEAD --no-mergesRELEASE-IT:CONFIG 212: { name: 'ci-test-service', latestVersion: '0.7.0-rc.2', version: '0.7.0-rc.3', changelog: '# [0.7.0-rc.3](https://gitlab.com/my-repo/repo/compare/v0.7.0-rc.2...v0.7.0-rc.3) (2025-04-07)\n' + '\n' + '\n' + '### Bug Fixes\n' + '\n' + '* intermediate ([1d46a08](https://gitlab.com/my-repo/repo/commit/1d46a0824dfde48003a166aa7fe792b7da66e341))\n' + '\n' + '\n' + '### Features\n' + '\n' + '* 1 ([1991cf2](https://gitlab.com/my-repo/repo/commit/1991cf2a472657f47db987a1199d7981128a6415))\n' + '* no-released yet ([4fa2d81](https://gitlab.com/my-repo/repo/commit/4fa2d81028a9d19416b25484351d9fe6357fabf9))\n' + '* released ([5b38c9c](https://gitlab.com/my-repo/repo/commit/5b38c9cdd387d7506bb00de390c59965e2ed2a83))'}🚀 Let's release ci-test-service (0.7.0-rc.2...0.7.0-rc.3)Changelog:# [0.7.0-rc.3](https://gitlab.com/my-repo/repo/compare/v0.7.0-rc.2...v0.7.0-rc.3) (2025-04-07)### Bug Fixes* intermediate ([1d46a08](https://gitlab.com/my-repo/repo/commit/1d46a0824dfde48003a166aa7fe792b7da66e341))### Features* 1 ([1991cf2](https://gitlab.com/my-repo/repo/commit/1991cf2a472657f47db987a1199d7981128a6415))* no-released yet ([4fa2d81](https://gitlab.com/my-repo/repo/commit/4fa2d81028a9d19416b25484351d9fe6357fabf9))* released ([5b38c9c](https://gitlab.com/my-repo/repo/commit/5b38c9cdd387d7506bb00de390c59965e2ed2a83))RELEASE-IT:CONFIG 212: { version: '0.7.0-rc.3', isPreRelease: true, preReleaseId: 'rc' }$ npm version 0.7.0-rc.3 --no-git-tag-versionv0.7.0-rc.3v0.7.0-rc.3RELEASE-IT:SHELL 212: { command: 'npm version 0.7.0-rc.3 --no-git-tag-version', options: {}, code: 0, stdout: 'v0.7.0-rc.3', stderr: ''}RELEASE-IT:CONFIG 212: { tagName: 'v0.7.0-rc.3' }RELEASE-IT:CONFIG 212: { tagName: 'v0.7.0-rc.3' }$ Writing changelog to undefined$ git tag --annotate --message Release 0.7.0-rc.3 v0.7.0-rc.3RELEASE-IT:SHELL 212: { command: [ 'git', 'tag', '--annotate', '--message', 'Release 0.7.0-rc.3', 'v0.7.0-rc.3' ], options: {}, stdout: '', stderr: ''}! gitlab releases#createRelease "Release 0.7.0-rc.3" (v0.7.0-rc.3)RELEASE-IT:GITLAB 212: { url: 'https://gitlab.com/api/v4/projects/my-repo%2Finfra%2Frepo/releases', json: { name: 'Release 0.7.0-rc.3', ref: 'HEAD', tag_name: 'v0.7.0-rc.3', tag_message: 'Release 0.7.0-rc.3', description: '# [0.7.0-rc.3](https://gitlab.com/my-repo/repo/compare/v0.7.0-rc.2...v0.7.0-rc.3) (2025-04-07)\n' + '\n' + '\n' + '### Bug Fixes\n' + '\n' + '* intermediate ([1d46a08](https://gitlab.com/my-repo/repo/commit/1d46a0824dfde48003a166aa7fe792b7da66e341))\n' + '\n' + '\n' + '### Features\n' + '\n' + '* 1 ([1991cf2](https://gitlab.com/my-repo/repo/commit/1991cf2a472657f47db987a1199d7981128a6415))\n' + '* not released yet ([4fa2d81](https://gitlab.com/my-repo/repo/commit/4fa2d81028a9d19416b25484351d9fe6357fabf9))\n' + '* could be released ([5b38c9c](https://gitlab.com/my-repo/repo/commit/5b38c9cdd387d7506bb00de390c59965e2ed2a83))' }}RELEASE-IT:GITLAB 212: { name: 'Release 0.7.0-rc.3', tag_name: 'v0.7.0-rc.3', description: '# [0.7.0-rc.3](https://gitlab.com/my-repo/repo/compare/v0.7.0-rc.2...v0.7.0-rc.3) (2025-04-07)\n' + '\n' + '\n' + '### Bug Fixes\n' + '\n' + '* intermediate ([1d46a08](https://gitlab.com/my-repo/repo/commit/1d46a0824dfde48003a166aa7fe792b7da66e341))\n' + '\n' + '\n' + '### Features\n' + '\n' + '* 1 ([1991cf2](https://gitlab.com/my-repo/repo/commit/1991cf2a472657f47db987a1199d7981128a6415))\n' + '* not released yet ([4fa2d81](https://gitlab.com/my-repo/repo/commit/4fa2d81028a9d19416b25484351d9fe6357fabf9))\n' + '* could be released ([5b38c9c](https://gitlab.com/my-repo/repo/commit/5b38c9cdd387d7506bb00de390c59965e2ed2a83))', created_at: '2025-04-07T20:04:54.054Z', released_at: '2025-04-07T20:04:54.054Z', upcoming_release: false, author: { id: x, username: 'x', name: 'x', state: 'active', locked: false, avatar_url: 'x', web_url: 'https://gitlab.com/x' }, commit: { id: 'd0bd831266a0dae79b24db4c0b6e7f63b5fc87d2', short_id: 'd0bd8312', created_at: '2025-04-07T16:02:11.000-04:00', parent_ids: [ '1991cf2a472657f47db987a1199d7981128a6415' ], title: 'feat: 2', message: 'feat: 2\n', author_name: 'x', author_email: 'x', authored_date: '2025-04-07T16:02:11.000-04:00', committer_name: 'x', committer_email: 'x', committed_date: '2025-04-07T16:02:11.000-04:00', trailers: {}, extended_trailers: {}, web_url: 'https://gitlab.com/my-repo/repo/-/commit/d0bd831266a0dae79b24db4c0b6e7f63b5fc87d2' }, commit_path: '/my-repo/repo/-/commit/d0bd831266a0dae79b24db4c0b6e7f63b5fc87d2', tag_path: '/my-repo/repo/-/tags/v0.7.0-rc.3', assets: { count: 4, sources: [ [Object], [Object], [Object], [Object] ], links: [] }, evidences: [], _links: { closed_issues_url: 'https://gitlab.com/my-repo/repo/-/issues?release_tag=v0.7.0-rc.3&scope=all&state=closed', closed_merge_requests_url: 'https://gitlab.com/my-repo/repo/-/merge_requests?release_tag=v0.7.0-rc.3&scope=all&state=closed', edit_url: 'https://gitlab.com/my-repo/repo/-/releases/v0.7.0-rc.3/edit', merged_merge_requests_url: 'https://gitlab.com/my-repo/repo/-/merge_requests?release_tag=v0.7.0-rc.3&scope=all&state=merged', opened_issues_url: 'https://gitlab.com/my-repo/repo/-/issues?release_tag=v0.7.0-rc.3&scope=all&state=opened', opened_merge_requests_url: 'https://gitlab.com/my-repo/repo/-/merge_requests?release_tag=v0.7.0-rc.3&scope=all&state=opened', self: 'https://gitlab.com/my-repo/repo/-/releases/v0.7.0-rc.3' }}gitlab releases#createRelease: doneRELEASE-IT:CONFIG 212: { isReleased: true, releaseUrl: 'https://gitlab.com/my-repo/repo/-/releases/v0.7.0-rc.3'}🔗 https://gitlab.com/my-repo/repo/-/releases/v0.7.0-rc.3🏁 Done (in 3s.)$ git log -n 5commit 1991cf2a472657f47db987a1199d7981128a6415Author: MeDate: Mon Apr 7 16:02:02 2025 -0400 feat: 1commit 4fa2d81028a9d19416b25484351d9fe6357fabf9Author: MeDate: Mon Apr 7 15:53:34 2025 -0400 feat: not released yetcommit 1d46a0824dfde48003a166aa7fe792b7da66e341Author: MeDate: Mon Apr 7 15:53:23 2025 -0400 fix: intermediatecommit 5b38c9cdd387d7506bb00de390c59965e2ed2a83Author: MeDate: Mon Apr 7 15:53:09 2025 -0400 feat: could be releasedcommit b02333f8464ca8ffef02dcd3422f5fb46c937fceAuthor: MeDate: Mon Apr 7 15:31:02 2025 -0400 feat: another debug$ git rev-parse --abbrev-ref HEADHEADNote that while the tag points to the wrong commit (feat: 2) the changelog generated is correct and starts withfeat: 1
Thank you for your help!