Skip to content

Commit

Permalink
Switch latestTag() to discard all tags except for full SemVer tags
Browse files Browse the repository at this point in the history
We use the regex `^v\d+\.\d+\.\d+$` to only keep fully qualified SemVer
tags when finding the newest tag. This ensures that the action also
works on repos which have major-version tags.
  • Loading branch information
simu committed Nov 6, 2023
1 parent 9cfb6b3 commit 5a2ef51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion __tests__/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ describe('latestTag', () => {
'v1.0.0',
'v1.2.2',
'foo-v1.0.0',
'bar'
'bar',
'v1'
)
getOctokitMock.mockImplementation(clientMock.mockFn)

Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function latestTag(): Promise<string> {
const tags = tagsResp
.map(({ name }) => name)
.filter(tag => {
return tag.startsWith('v')
return /^v\d+\.\d+\.\d+$/.test(tag)
})
.sort(rcompare)

Expand Down

0 comments on commit 5a2ef51

Please sign in to comment.