Skip to content

Commit e3137e4

Browse files
committed
feat(core): fetch option for tag step to update local tags before tagging
1 parent 5a60952 commit e3137e4

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

packages/core/src/releaser.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,26 @@ export class Releaser<
281281
gitClient
282282
} = this
283283
const { dryRun } = this.options
284+
const {
285+
fetch,
286+
...tagOptions
287+
} = {
288+
...this.stepsOptions.tag,
289+
...options
290+
}
284291

285292
logger.info('tag', 'Tagging version...')
286293

294+
if (fetch) {
295+
logger.verbose('tag', 'Fetching fresh tags from the remote repository...')
296+
297+
if (!dryRun) {
298+
await gitClient.fetch({
299+
tags: true
300+
})
301+
}
302+
}
303+
287304
const tags = await project.getTags()
288305

289306
this.state.tags = tags.length > 0
@@ -300,8 +317,7 @@ export class Releaser<
300317

301318
if (!dryRun) {
302319
await gitClient.tag({
303-
...this.stepsOptions.tag,
304-
...options,
320+
...tagOptions,
305321
name: tag
306322
})
307323
}

packages/core/src/releaser.types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ export interface ReleaserCheckoutOptions {
5454

5555
export type ReleaserCommitOptions = Omit<GitCommitParams, 'verify' | 'files' | 'message'>
5656

57-
export type ReleaserTagOptions = Omit<GitTagParams, 'name' | 'message'>
57+
export interface ReleaserTagOptions extends Omit<GitTagParams, 'name' | 'message'> {
58+
/**
59+
* Fetch fresh tags from the remote repository before tagging.
60+
*/
61+
fetch?: boolean
62+
}
5863

5964
export type ReleaserPushOptions = Omit<GitPushParams, 'verify' | 'tags' | 'followTags'>
6065

0 commit comments

Comments
 (0)