Skip to content
Closed
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
25 changes: 12 additions & 13 deletions .github/workflows/sea.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Single Executable Application
name: Compiled Executable

on:
push:
Expand All @@ -14,39 +14,38 @@ jobs:
os: [ubuntu-latest, macos-latest, macos-latest-large, windows-latest]
include:
- os: ubuntu-latest
run_script: sea:linux
artifact_name: symbol-upload-linux
file_name: symbol-upload-linux
- os: macos-latest
run_script: sea:macos
artifact_name: symbol-upload-macos
file_name: symbol-upload-macos
- os: macos-latest-large
run_script: sea:macos
artifact_name: symbol-upload-macos-intel
file_name: symbol-upload-macos
- os: windows-latest
run_script: sea:windows
artifact_name: symbol-upload-windows.exe
file_name: symbol-upload-windows.exe

steps:
- name: ☑️ Checkout
uses: actions/checkout@v4

- name: ⚙️ Setup Node.js
uses: actions/setup-node@v4
- name: ⚙️ Setup Bun
uses: oven-sh/setup-bun@v2
with:
node-version: '22'
bun-version: 1.3.13

- name: 🏗️ Install Dependencies
run: npm ci
run: bun install

- name: 📦 Bundle Worker
run: bun build ./src/compression.js --outfile ./dist/compression.bundle.js --target=bun

- name: 📦 Run Pkg
run: npm run ${{ matrix.run_script }} # Executes the script based on the operating system
- name: 📦 Compile Executable
run: bun build --compile --minify ./bin/compile-entry.ts --outfile ./dist/${{ matrix.file_name }}

- name: ⬆️ Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact_name }}
path: dist/${{ matrix.file_name }} # Uploads the artifact with a platform-specific name and path
path: dist/${{ matrix.file_name }}
30 changes: 2 additions & 28 deletions bin/command-line-definitions.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { OptionDefinition as ArgDefinition } from "command-line-args";
import { Section, OptionDefinition as UsageDefinition } from "command-line-usage";
import { existsSync, readFileSync } from "fs";
import { join } from "node:path";
import { getAsset, isSea } from "node:sea";
import packageJson from '../package.json';

const packageVersion = getPackageVersion();
const packageVersion = packageJson.version;

export type CommandLineDefinition = ArgDefinition & UsageDefinition;

Expand Down Expand Up @@ -138,27 +136,3 @@ export const usageDefinitions: Array<Section> = [
]
}
];

function getPackageVersion(): string {
if (isSea()) {
return JSON.parse(`${getAsset('package.json', 'utf-8')}`).version;
}

const path = [
join(__dirname, 'package.json'),
join(__dirname, '../package.json'),
join(__dirname, '../../package.json'),
].find((path) => existsSync(path));

if (!path) {
throw new Error('Could not find package.json');
}

const packageJson = readFileSync(path, 'utf-8').toString();

try {
return JSON.parse(packageJson).version;
} catch {
throw new Error('Could not parse package.json');
}
}
7 changes: 7 additions & 0 deletions bin/compile-entry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Entry point for `bun build --compile`. Embeds the pre-bundled worker
// as a file asset and stores its path for preload.ts before running the app.
// The dynamic import ensures __embeddedWorkerPath is set before the app starts,
// since static imports are hoisted and evaluated before the module body.
import compressionWorkerBundle from "../dist/compression.bundle.js" with { type: "file" };
(globalThis as any).__embeddedWorkerPath = compressionWorkerBundle;
await import("./index.ts");
622 changes: 622 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

Loading
Loading