Skip to content

Commit 0a85390

Browse files
fix(publish): use 'previous' npm tag for old releases (#249)
* fix(publish): use 'previous' npm tag for old releases * Move line * Add changeset
1 parent 0f6677a commit 0a85390

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

.changeset/giant-wombats-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/publish-config': patch
3+
---
4+
5+
fix(publish): use 'previous' npm tag for old releases

packages/publish-config/src/index.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export const publish = async (options) => {
4949

5050
const branchName = /** @type {string} */ (branch ?? currentGitBranch())
5151
const isMainBranch = branchName === 'main'
52-
const npmTag = isMainBranch ? 'latest' : branchName
5352

5453
/** @type {import('./index.js').BranchConfig | undefined} */
5554
const branchConfig = branchConfigs[branchName]
@@ -179,12 +178,6 @@ export const publish = async (options) => {
179178
if (commit.body.includes('BREAKING CHANGE')) {
180179
releaseLevel = Math.max(releaseLevel, 2)
181180
}
182-
if (
183-
commit.subject.includes('RELEASE_ALL') ||
184-
commit.body.includes('RELEASE_ALL')
185-
) {
186-
RELEASE_ALL = true
187-
}
188181
}
189182
return releaseLevel
190183
},
@@ -211,19 +204,21 @@ export const publish = async (options) => {
211204
recommendedReleaseLevel = 0
212205
}
213206

214-
const releaseType = branchConfig.prerelease
215-
? 'prerelease'
216-
: /** @type {const} */ ({ 0: 'patch', 1: 'minor', 2: 'major' })[
217-
recommendedReleaseLevel
218-
]
207+
const releaseType = /** @type {const} */ ({
208+
0: 'patch',
209+
1: 'minor',
210+
2: 'major',
211+
})[recommendedReleaseLevel]
219212

220213
if (!releaseType) {
221214
throw new Error(`Invalid release level: ${recommendedReleaseLevel}`)
222215
}
223216

224217
const version = tag
225218
? semver.parse(tag)?.version
226-
: semver.inc(latestTag, releaseType, npmTag)
219+
: branchConfig.prerelease
220+
? semver.inc(latestTag, 'prerelease', branchName)
221+
: semver.inc(latestTag, releaseType)
227222

228223
if (!version) {
229224
throw new Error(
@@ -459,6 +454,13 @@ export const publish = async (options) => {
459454
)
460455
}
461456

457+
/** 'latest' for current version, 'previous' for old versions, and custom for prereleases */
458+
const npmTag = isMainBranch
459+
? 'latest'
460+
: branchConfig.previousVersion
461+
? 'previous'
462+
: branchName
463+
462464
console.info()
463465
console.info(`Publishing all packages to npm with tag "${npmTag}"`)
464466

0 commit comments

Comments
 (0)