Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion .github/actions/build-refs/action/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getOctokit } from '@actions/github'
import * as core from '@actions/core'
import * as semver from 'semver'

export type Repo = 'buildroot' | 'monorepo'
export type BuildType = 'develop' | 'release'
Expand Down Expand Up @@ -66,7 +67,41 @@ function latestTagPrefixFor(repo: Repo, variant: Variant): string[] {
}

export function latestTag(tagRefs: GitHubApiTag[]): Tag | null {
return (tagRefs.at(-1)?.ref as Tag | null | undefined) ?? null
if (tagRefs.length === 0) return null

// Extract and parse version numbers from tag refs
const tagVersions = tagRefs
.map(tag => {
const tagName = tag.ref.replace('refs/tags/', '')

// Handle v* tags (e.g., "v1.19.4")
if (tagName.startsWith('v')) {
const version = tagName.substring(1)
return { tag: tag.ref, version, isValid: semver.valid(version) }
}

// Handle internal@* tags (e.g., "[email protected]")
if (tagName.startsWith('internal@')) {
const version = tagName.substring(9) // Remove "internal@"
return { tag: tag.ref, version, isValid: semver.valid(version) }
}

// Handle ot3@* tags (e.g., "[email protected]")
if (tagName.startsWith('ot3@')) {
const version = tagName.substring(4) // Remove "ot3@"
return { tag: tag.ref, version, isValid: semver.valid(version) }
}

// Unknown tag format
return { tag: tag.ref, version: null, isValid: false }
})
.filter(tv => tv.isValid) // Only keep valid semantic versions

if (tagVersions.length === 0) return null

// Sort by semantic version and return the latest
tagVersions.sort((a, b) => semver.compare(a.version!, b.version!))
return tagVersions[tagVersions.length - 1].tag
}

function restDetailsFor(input: Repo): { owner: string; repo: string } {
Expand Down
34,678 changes: 29,414 additions & 5,264 deletions .github/actions/build-refs/dist/index.js

Large diffs are not rendered by default.

Loading
Loading