@@ -60,17 +60,28 @@ function read(file) {
6060}
6161
6262// ---- versions ----
63+ // The numbering restarts with the winter update: the first entry published on or after ERA_START (the first day of
64+ // winter on the site, the day after FALL_TO in e63334287a3deaa3/seasons.js) is ERA_MAJOR.01, and later ones count up
65+ // from there: 2.02, 2.03 ... 2.09, 2.10, with fixes in between as 2.01.1, 2.01.2. From ERA_MAJOR on, the middle
66+ // number is always written with at least two digits ("2.01", never "2.1"). Entries published before that day keep
67+ // the old numbering (1.58 -> 1.59, 1.58.1), and nothing already in news.js is ever renumbered.
68+ const ERA_START = '2026-11-27' ;
69+ const ERA_MAJOR = 2 ;
6370const parseV = ( s ) => s . split ( '.' ) . map ( Number ) ;
6471const cmpV = ( a , b ) => { for ( let i = 0 ; i < 3 ; i ++ ) { const d = ( a [ i ] || 0 ) - ( b [ i ] || 0 ) ; if ( d ) return d ; } return 0 ; } ;
6572function latestVersion ( src ) {
73+ // compared number by number, so 2.01 is after every 1.x and 2.10 is after 2.09 (never as text or as a decimal)
6674 const all = [ ...src . matchAll ( / \b v e r s i o n : \s * ' ( \d + (?: \. \d + ) { 1 , 2 } ) ' / g) ] . map ( ( m ) => parseV ( m [ 1 ] ) ) ;
6775 if ( ! all . length ) throw new Error ( `no versions found in ${ NEWS_JS } ` ) ;
6876 return all . sort ( cmpV ) . pop ( ) ;
6977}
70- function bump ( v , kind ) {
78+ const minorText = ( major , minor ) => ( major >= ERA_MAJOR ? String ( minor ) . padStart ( 2 , '0' ) : String ( minor ) ) ;
79+ function bump ( v , kind , publishedOn ) {
80+ // the first entry of the new numbering, whatever its kind
81+ if ( v [ 0 ] < ERA_MAJOR && publishedOn >= ERA_START ) return `${ ERA_MAJOR } .01` ;
7182 // a new game or a big feature bumps the minor number and drops the patch; a fix (or a teaser) bumps the patch
72- if ( kind === 'game' || kind === 'feature' ) return `${ v [ 0 ] } .${ ( v [ 1 ] || 0 ) + 1 } ` ;
73- return `${ v [ 0 ] } .${ v [ 1 ] || 0 } .${ ( v [ 2 ] || 0 ) + 1 } ` ;
83+ if ( kind === 'game' || kind === 'feature' ) return `${ v [ 0 ] } .${ minorText ( v [ 0 ] , ( v [ 1 ] || 0 ) + 1 ) } ` ;
84+ return `${ v [ 0 ] } .${ minorText ( v [ 0 ] , v [ 1 ] || 0 ) } .${ ( v [ 2 ] || 0 ) + 1 } ` ;
7485}
7586
7687// ---- writing in news.js's own style ----
@@ -96,6 +107,8 @@ function insertAfter(src, marker, text, file) {
96107}
97108
98109function today ( ) {
110+ // NEWS_TODAY=YYYY-MM-DD pretends it is that day, for trying a publish out by hand; the workflow never sets it
111+ if ( / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / . test ( process . env . NEWS_TODAY || '' ) ) return process . env . NEWS_TODAY ;
99112 return new Intl . DateTimeFormat ( 'en-CA' , { timeZone : TZ , year : 'numeric' , month : '2-digit' , day : '2-digit' } ) . format ( new Date ( ) ) ;
100113}
101114
@@ -132,7 +145,8 @@ function publish() {
132145 const done = [ ] ;
133146 for ( const f of files ) {
134147 const e = read ( f ) . entry ;
135- const version = e . noVersion ? null : bump ( latestVersion ( js ) , e . kind ) ;
148+ // the numbering goes by the day the entry is published, not by a "date" the file sets for itself
149+ const version = e . noVersion ? null : bump ( latestVersion ( js ) , e . kind , today ( ) ) ;
136150 const date = e . date || today ( ) ;
137151 js = insertAfter ( js , 'var NEWS = [' , render ( e , date , version ) , NEWS_JS ) ;
138152 const pairs = Object . entries ( e . es || { } ) ;
0 commit comments