11/**
22 * Build standalone `bl` binaries with Bun --compile, then pack each as a
3- * per-platform `.zip` via binary-zip.mjs (Release / OSS download asset ).
3+ * per-platform `.zip` (all OS) plus `.tar.gz` on darwin/linux (Release / OSS).
44 *
55 * Used by lib/binary-release.mjs (and publish-stable / publish-channel orchestrators).
66 * Debug:
@@ -21,6 +21,7 @@ import {
2121 rollingManifestChannelId ,
2222 rollingManifestFileName ,
2323} from "./binary-options.mjs" ;
24+ import { ensureTar , tarOne } from "./binary-tar.mjs" ;
2425import { ensureZip , zipOne } from "./binary-zip.mjs" ;
2526
2627const BINARY_COMPILE = fileURLToPath ( new URL ( "./binary-compile.mjs" , import . meta. url ) ) ;
@@ -42,14 +43,27 @@ export function binaryInnerName(version, { os, arch, exe }) {
4243 return `bl-${ version } -${ os } -${ arch } ${ exe ? ".exe" : "" } ` ;
4344}
4445
45- /** Release asset basename: `bl-<ver>-<os>-<arch>.zip`. */
46+ /** Release zip basename: `bl-<ver>-<os>-<arch>.zip` (install.ps1 / bl update / old install.sh) . */
4647export function binaryAssetName ( version , { os, arch } ) {
4748 return `bl-${ version } -${ os } -${ arch } .zip` ;
4849}
4950
50- /** Full matrix zip basenames for a version (order matches BINARY_TARGETS). */
51+ /** Unix install.sh default archive: `bl-<ver>-<os>-<arch>.tar.gz`. */
52+ export function binaryTarAssetName ( version , { os, arch } ) {
53+ return `bl-${ version } -${ os } -${ arch } .tar.gz` ;
54+ }
55+
56+ export function unixTarTarget ( target ) {
57+ return target . os !== "windows" ;
58+ }
59+
60+ /** Full matrix: zip for every target, plus tar.gz for darwin/linux. */
5161export function matrixAssetNames ( version ) {
52- return BINARY_TARGETS . map ( ( target ) => binaryAssetName ( version , target ) ) ;
62+ return BINARY_TARGETS . flatMap ( ( target ) => {
63+ const zipName = binaryAssetName ( version , target ) ;
64+ if ( ! unixTarTarget ( target ) ) return [ zipName ] ;
65+ return [ zipName , binaryTarAssetName ( version , target ) ] ;
66+ } ) ;
5367}
5468
5569function log ( message = "" ) {
@@ -156,22 +170,32 @@ function compileOne({ bunTarget, os, arch, exe }, version, outdir, entry) {
156170}
157171
158172function writeChecksums ( outdir , artifacts ) {
159- const lines = artifacts . map ( ( item ) => `${ item . sha256 } ${ item . fileName } ` ) ;
173+ const lines = [ ] ;
174+ for ( const item of artifacts ) {
175+ lines . push ( `${ item . sha256 } ${ item . fileName } ` ) ;
176+ if ( item . tarFileName && item . tarSha256 ) {
177+ lines . push ( `${ item . tarSha256 } ${ item . tarFileName } ` ) ;
178+ }
179+ }
160180 writeFileSync ( join ( outdir , "SHA256SUMS" ) , `${ lines . join ( "\n" ) } \n` ) ;
161181}
162182
163- /** Write the rolling channel manifest (`latest.json` / `sync-release.json`) with per-platform zip + sha256 . */
183+ /** Write the rolling channel manifest (`latest.json` / `sync-release.json`) with per-platform zip + optional tar.gz . */
164184function writeChannelManifest ( outdir , version , artifacts , mode ) {
165185 const channel = rollingManifestChannelId ( mode ) ;
166186 const assets = Object . fromEntries (
167- artifacts . map ( ( item ) => [
168- `${ item . os } -${ item . arch } ` ,
169- {
187+ artifacts . map ( ( item ) => {
188+ const asset = {
170189 file : item . fileName ,
171190 sha256 : item . sha256 ,
172191 inner : item . innerName ,
173- } ,
174- ] ) ,
192+ } ;
193+ if ( item . tarFileName && item . tarSha256 ) {
194+ asset . tar = item . tarFileName ;
195+ asset . tarSha256 = item . tarSha256 ;
196+ }
197+ return [ `${ item . os } -${ item . arch } ` , asset ] ;
198+ } ) ,
175199 ) ;
176200 const manifest = {
177201 name : "bailian-cli" ,
@@ -203,14 +227,36 @@ function smokeTestHostBinary(compiled, outdir) {
203227 }
204228}
205229
206- /** Compile binaries into `outdir`, zip per platform, write checksums (+ channel manifest). */
230+ function packOne ( compiled , version , outdir ) {
231+ let tarMeta = null ;
232+ if ( unixTarTarget ( compiled ) ) {
233+ tarMeta = tarOne ( compiled , {
234+ outdir,
235+ tarFileName : binaryTarAssetName ( version , compiled ) ,
236+ log,
237+ } ) ;
238+ }
239+ const zipMeta = zipOne ( compiled , {
240+ outdir,
241+ zipFileName : binaryAssetName ( version , compiled ) ,
242+ log,
243+ } ) ;
244+ return {
245+ ...zipMeta ,
246+ tarFileName : tarMeta ?. fileName ,
247+ tarSha256 : tarMeta ?. sha256 ,
248+ } ;
249+ }
250+
251+ /** Compile binaries into `outdir`, zip (+ unix tar.gz) per platform, write checksums (+ channel manifest). */
207252export function buildBinaryArtifacts ( rawOptions = { } ) {
208253 const options = normalizeBuildOptions ( rawOptions ) ;
209254 const { outdir, mode, channel } = options ;
210255 const bunVersion = ensureBun ( ) ;
211256 ensureZip ( ) ;
212257 const version = cliVersion ( ) ;
213258 const targets = resolveTargets ( options ) ;
259+ if ( targets . some ( ( target ) => unixTarTarget ( target ) ) ) ensureTar ( ) ;
214260
215261 mkdirSync ( outdir , { recursive : true } ) ;
216262 log ( `bun ${ bunVersion } ` ) ;
@@ -220,9 +266,7 @@ export function buildBinaryArtifacts(rawOptions = {}) {
220266
221267 const compiled = targets . map ( ( target ) => compileOne ( target , version , outdir , CLI_ENTRY ) ) ;
222268 smokeTestHostBinary ( compiled , outdir ) ;
223- const artifacts = compiled . map ( ( item ) =>
224- zipOne ( item , { outdir, zipFileName : binaryAssetName ( version , item ) , log } ) ,
225- ) ;
269+ const artifacts = compiled . map ( ( item ) => packOne ( item , version , outdir ) ) ;
226270 writeChecksums ( outdir , artifacts ) ;
227271
228272 const extras = [ "SHA256SUMS" ] ;
@@ -231,6 +275,9 @@ export function buildBinaryArtifacts(rawOptions = {}) {
231275 log ( `\nBuilt ${ artifacts . length } zip(s):` ) ;
232276 for ( const item of artifacts ) {
233277 log ( ` ${ item . fileName } ${ item . sha256 . slice ( 0 , 12 ) } … (inner ${ item . innerName } )` ) ;
278+ if ( item . tarFileName ) {
279+ log ( ` ${ item . tarFileName } ${ item . tarSha256 . slice ( 0 , 12 ) } …` ) ;
280+ }
234281 }
235282 log ( `Also wrote ${ extras . join ( ", " ) } ` ) ;
236283 return {
0 commit comments