Skip to content
Merged
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
21 changes: 20 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,33 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Resolve build version
id: version
shell: bash
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "release" ]; then
case "$RELEASE_TAG" in
v[0-9]*) version="${RELEASE_TAG#v}" ;;
*) echo "Release tag must use the vX.Y.Z format: $RELEASE_TAG" >&2; exit 1 ;;
esac
else
version="$(node -p "require('./package.json').version")"
fi
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Build SEA binary
env:
B4FUN_AI_VERSION: ${{ steps.version.outputs.version }}
run: npm run build:sea

- name: Smoke test SEA binary
shell: bash
run: |
set -euo pipefail
expected_version="$(node -p "require('./package.json').version")"
expected_version="${{ steps.version.outputs.version }}"
actual_version="$(dist/sea/ai --version)"
test "$actual_version" = "$expected_version"
dist/sea/ai shell init bash --name ai >/dev/null
Expand Down
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Guidance for future work in this repository.
## Versioning
- `package.json` is the source of truth for the project version.
- Do not maintain a separate checked-in version file.
- The standalone SEA build injects the package version at build time.
- The standalone SEA build uses `B4FUN_AI_VERSION` when set and otherwise injects the package version.
- When bumping a release version, update:
- `package.json`
- `package-lock.json`
Expand All @@ -33,7 +33,7 @@ Guidance for future work in this repository.

## Release workflow guardrails
- The release workflow should smoke test the SEA binary.
- The smoke test should confirm `dist/sea/ai --version` matches `package.json`.
- The release smoke test should confirm `dist/sea/ai --version` matches the release tag without its leading `v`.
- If the release artifact fails, check whether the issue is:
- version mismatch
- runtime access to repo files that do not exist in SEA
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-sea.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fileURLToPath } from "node:url";

const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const packageJson = JSON.parse(fs.readFileSync(path.join(rootDir, "package.json"), "utf8"));
const buildVersion = process.env.B4FUN_AI_VERSION || packageJson.version;
const distDir = path.join(rootDir, "dist", "sea");
const bundlePath = path.join(distDir, "ai.mjs");
const seaConfigPath = path.join(distDir, "sea-config.json");
Expand Down Expand Up @@ -54,7 +55,7 @@ await build({
format: "esm",
target: "node25",
define: {
"process.env.B4FUN_AI_VERSION": JSON.stringify(packageJson.version),
"process.env.B4FUN_AI_VERSION": JSON.stringify(buildVersion),
},
banner: {
js: 'import { createRequire as __seaCreateRequire } from "node:module"; const require = globalThis.require ?? __seaCreateRequire(import.meta.url);',
Expand Down
Loading