@@ -6,7 +6,8 @@ const { load } = require("js-yaml");
66
77const OWNER = "codefresh-io" ;
88const REPO = "gitops-runtime-helm" ;
9- const LATEST_PATTERN = / ^ ( \d { 4 } ) \. ( \d { 1 , 2 } ) - ( \d + ) $ / ;
9+ const LATEST_PATTERN = / ^ ( \d { 2 } ) \. ( \d { 1 , 2 } ) - ( \d + ) $ / ; // Format: YY.MM-patch (e.g., 25.04-1)
10+ const MIN_STABLE_VERSION = "1.0.0" ;
1011const TOKEN = process . env . GITHUB_TOKEN ;
1112const SECURITY_FIXES_STRING =
1213 process . env . SECURITY_FIXES_STRING || "### Security Fixes:" ;
@@ -22,6 +23,11 @@ if (!TOKEN) {
2223
2324const octokit = new Octokit ( { auth : TOKEN } ) ;
2425
26+ /**
27+ * Detect channel based on version format
28+ * - Latest: YY.MM-patch format (e.g., 25.04-1)
29+ * - Stable: Semver format starting from 1.0.0 (e.g., 1.2.3)
30+ */
2531function detectChannel ( version ) {
2632 const match = version . match ( LATEST_PATTERN ) ;
2733 if ( match ) {
@@ -30,12 +36,26 @@ function detectChannel(version) {
3036 return "latest" ;
3137 }
3238 }
39+
3340 return "stable" ;
3441}
3542
43+ function isValidChannelVersion ( normalized , channel ) {
44+ if ( ! semver . valid ( normalized ) ) {
45+ return false ;
46+ }
47+
48+ if ( channel === "stable" ) {
49+ return semver . gte ( normalized , MIN_STABLE_VERSION ) ;
50+ }
51+
52+ return true ;
53+ }
54+
3655/**
3756 * Normalize version for semver validation
38- * Converts: 2025.01-1 → 2025.1.1
57+ * - Latest channel: 25.01-1 → 25.1.1
58+ * - Stable channel: 1.2.3 → 1.2.3 (no change)
3959 */
4060function normalizeVersion ( version , channel ) {
4161 if ( channel === "latest" ) {
@@ -50,10 +70,6 @@ function normalizeVersion(version, channel) {
5070 return version ;
5171}
5272
53- function isValidVersion ( normalized ) {
54- return ! ! semver . valid ( normalized ) ;
55- }
56-
5773function compareVersions ( normA , normB ) {
5874 try {
5975 return semver . compare ( normA , normB ) ;
@@ -145,11 +161,14 @@ function processReleases(rawReleases) {
145161 }
146162
147163 const channel = detectChannel ( version ) ;
148-
149164 const normalized = normalizeVersion ( version , channel ) ;
150165
151- if ( ! isValidVersion ( normalized ) ) {
152- console . log ( ` ⚠️ Skipping invalid version: ${ version } ` ) ;
166+ if ( ! isValidChannelVersion ( normalized , channel ) ) {
167+ const reason =
168+ channel === "stable"
169+ ? `not valid semver >= ${ MIN_STABLE_VERSION } `
170+ : "not valid semver" ;
171+ console . log ( ` ⚠️ Skipping invalid ${ channel } version: ${ version } (${ reason } )` ) ;
153172 skipped ++ ;
154173 continue ;
155174 }
0 commit comments