Skip to content

Commit

Permalink
fix: improve release script (#8914)
Browse files Browse the repository at this point in the history
* chore: fetch before checking in progress

* chore: remove redundant fetches

* chore: check since last release

* chore: trigger ci

---------

Co-authored-by: gomes <17035424+gomesalexandre@users.noreply.github.com>
  • Loading branch information
0xApotheosis and gomesalexandre authored Feb 24, 2025
1 parent 48d1929 commit fbd3a8a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,17 @@ type GetCommitMessagesReturn = {
}
type GetCommitMessages = (branch: GetCommitMessagesArgs) => Promise<GetCommitMessagesReturn>
const getCommits: GetCommitMessages = async branch => {
// Get the last release tag
const latestTag = await getLatestSemverTag()

// If we have a last release tag, base the diff on that
const range = latestTag ? `${latestTag}..origin/${branch}` : `origin/main..origin/${branch}`

const { all, total } = await git().log([
'--oneline',
'--first-parent',
'--pretty=format:%s', // no hash, just conventional commit style
`origin/main..origin/${branch}`,
range,
])

const messages = all.map(({ hash }) => hash)
Expand All @@ -119,7 +125,6 @@ const assertCommitsToRelease = (total: number) => {
}

const doRegularRelease = async () => {
await fetch()
const { messages, total } = await getCommits('develop')
assertCommitsToRelease(total)
await inquireProceedWithCommits(messages, 'create')
Expand Down Expand Up @@ -224,7 +229,6 @@ const createRelease = async () => {
}

const mergeRelease = async () => {
await fetch()
const { messages, total } = await getCommits('release')
assertCommitsToRelease(total)
await inquireProceedWithCommits(messages, 'merge')
Expand Down Expand Up @@ -266,6 +270,7 @@ const main = async () => {
await assertIsCleanRepo()
await assertGhInstalled()
await assertGhAuth()
await fetch()
;(await isReleaseInProgress()) ? await mergeRelease() : await createRelease()
}

Expand Down

0 comments on commit fbd3a8a

Please sign in to comment.