chore(packages): align platform package dirs
This commit is contained in:
@@ -122,7 +122,7 @@ jobs:
|
||||
env:
|
||||
VERSION: ${{ steps.validate.outputs.version }}
|
||||
run: |
|
||||
cd packages/${{ matrix.platform }}
|
||||
cd "packages/oh-my-opencode-${{ matrix.platform }}"
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
- name: Set root package version
|
||||
@@ -188,6 +188,7 @@ jobs:
|
||||
shell: bash
|
||||
command: |
|
||||
PLATFORM="${{ matrix.platform }}"
|
||||
PACKAGE_DIR="packages/oh-my-opencode-${PLATFORM}"
|
||||
case "$PLATFORM" in
|
||||
darwin-arm64) TARGET="bun-darwin-arm64" ;;
|
||||
darwin-x64) TARGET="bun-darwin-x64" ;;
|
||||
@@ -203,9 +204,9 @@ jobs:
|
||||
esac
|
||||
|
||||
if [[ "$PLATFORM" == windows-* ]]; then
|
||||
OUTPUT="packages/${PLATFORM}/bin/oh-my-opencode.exe"
|
||||
OUTPUT="${PACKAGE_DIR}/bin/oh-my-opencode.exe"
|
||||
else
|
||||
OUTPUT="packages/${PLATFORM}/bin/oh-my-opencode"
|
||||
OUTPUT="${PACKAGE_DIR}/bin/oh-my-opencode"
|
||||
fi
|
||||
|
||||
bun build src/cli/index.ts --compile --minify --target=$TARGET --outfile=$OUTPUT
|
||||
@@ -216,7 +217,7 @@ jobs:
|
||||
- name: Ad-hoc sign darwin binary
|
||||
if: steps.check.outputs.skip != 'true' && startsWith(matrix.platform, 'darwin-')
|
||||
run: |
|
||||
BINARY="packages/${{ matrix.platform }}/bin/oh-my-opencode"
|
||||
BINARY="packages/oh-my-opencode-${{ matrix.platform }}/bin/oh-my-opencode"
|
||||
echo "Initial state:"
|
||||
codesign -dvvv "$BINARY" 2>&1 || true
|
||||
echo "Removing any existing signature:"
|
||||
@@ -231,7 +232,8 @@ jobs:
|
||||
if: steps.check.outputs.skip != 'true'
|
||||
run: |
|
||||
PLATFORM="${{ matrix.platform }}"
|
||||
cd packages/${PLATFORM}
|
||||
PACKAGE_DIR="packages/oh-my-opencode-${PLATFORM}"
|
||||
cd "$PACKAGE_DIR"
|
||||
|
||||
if [[ "$PLATFORM" == windows-* ]]; then
|
||||
# Windows: use 7z (pre-installed on windows-latest)
|
||||
@@ -330,17 +332,18 @@ jobs:
|
||||
if: steps.check.outputs.skip_all != 'true' && steps.download.outcome == 'success'
|
||||
run: |
|
||||
PLATFORM="${{ matrix.platform }}"
|
||||
mkdir -p packages/${PLATFORM}
|
||||
PACKAGE_DIR="packages/oh-my-opencode-${PLATFORM}"
|
||||
mkdir -p "$PACKAGE_DIR"
|
||||
|
||||
if [[ "$PLATFORM" == windows-* ]]; then
|
||||
unzip binary-${PLATFORM}.zip -d packages/${PLATFORM}/
|
||||
unzip binary-${PLATFORM}.zip -d "$PACKAGE_DIR/"
|
||||
else
|
||||
tar -xzvf binary-${PLATFORM}.tar.gz -C packages/${PLATFORM}/
|
||||
tar -xzvf binary-${PLATFORM}.tar.gz -C "$PACKAGE_DIR/"
|
||||
fi
|
||||
|
||||
echo "Extracted contents:"
|
||||
ls -la packages/${PLATFORM}/
|
||||
ls -la packages/${PLATFORM}/bin/
|
||||
ls -la "$PACKAGE_DIR/"
|
||||
ls -la "$PACKAGE_DIR/bin/"
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
if: steps.check.outputs.skip_all != 'true' && steps.download.outcome == 'success'
|
||||
@@ -369,7 +372,7 @@ jobs:
|
||||
DIST_TAG: ${{ steps.validate.outputs.dist_tag }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
run: |
|
||||
cd packages/${{ matrix.platform }}
|
||||
cd "packages/oh-my-opencode-${{ matrix.platform }}"
|
||||
|
||||
if [ -n "$DIST_TAG" ]; then
|
||||
npm publish --access public --provenance --tag "$DIST_TAG" --loglevel verbose
|
||||
@@ -384,7 +387,7 @@ jobs:
|
||||
DIST_TAG: ${{ steps.validate.outputs.dist_tag }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
run: |
|
||||
cd packages/${{ matrix.platform }}
|
||||
cd "packages/oh-my-opencode-${{ matrix.platform }}"
|
||||
|
||||
# Rename package for oh-my-openagent
|
||||
jq --arg name "oh-my-openagent-${{ matrix.platform }}" \
|
||||
|
||||
@@ -222,8 +222,9 @@ jobs:
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
for platform in darwin-arm64 darwin-x64 darwin-x64-baseline linux-x64 linux-x64-baseline linux-arm64 linux-x64-musl linux-x64-musl-baseline linux-arm64-musl windows-x64 windows-x64-baseline; do
|
||||
jq --arg v "$VERSION" '.version = $v' "packages/${platform}/package.json" > tmp.json
|
||||
mv tmp.json "packages/${platform}/package.json"
|
||||
package_dir="packages/oh-my-opencode-${platform}"
|
||||
jq --arg v "$VERSION" '.version = $v' "${package_dir}/package.json" > tmp.json
|
||||
mv tmp.json "${package_dir}/package.json"
|
||||
done
|
||||
|
||||
jq --arg v "$VERSION" '.optionalDependencies = (.optionalDependencies | to_entries | map(.value = $v) | from_entries)' package.json > tmp.json && mv tmp.json package.json
|
||||
@@ -344,8 +345,9 @@ jobs:
|
||||
jq --arg v "$VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
|
||||
|
||||
for platform in darwin-arm64 darwin-x64 darwin-x64-baseline linux-x64 linux-x64-baseline linux-arm64 linux-x64-musl linux-x64-musl-baseline linux-arm64-musl windows-x64 windows-x64-baseline; do
|
||||
jq --arg v "$VERSION" '.version = $v' "packages/${platform}/package.json" > tmp.json
|
||||
mv tmp.json "packages/${platform}/package.json"
|
||||
package_dir="packages/oh-my-opencode-${platform}"
|
||||
jq --arg v "$VERSION" '.version = $v' "${package_dir}/package.json" > tmp.json
|
||||
mv tmp.json "${package_dir}/package.json"
|
||||
done
|
||||
|
||||
jq --arg v "$VERSION" '.optionalDependencies = (.optionalDependencies | to_entries | map(.value = $v) | from_entries)' package.json > tmp.json && mv tmp.json package.json
|
||||
@@ -356,7 +358,7 @@ jobs:
|
||||
run: |
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config user.name "github-actions[bot]"
|
||||
git add package.json packages/*/package.json
|
||||
git add package.json packages/oh-my-opencode-*/package.json
|
||||
git diff --cached --quiet || git commit -m "release: v${VERSION}"
|
||||
|
||||
- name: Create release tag
|
||||
|
||||
@@ -32,26 +32,27 @@ describe("build-binaries", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("has correct directory names for baseline platforms", async () => {
|
||||
it("uses exact package names as platform package directories", async () => {
|
||||
// given
|
||||
const module = await import("./build-binaries.ts");
|
||||
const platforms = (module as { PLATFORMS: { dir: string; target: string }[] }).PLATFORMS;
|
||||
const platforms = (module as { PLATFORMS: { packageName: string; packageDir: string }[] }).PLATFORMS;
|
||||
|
||||
// when
|
||||
const baselinePlatforms = platforms.filter((p) => p.target.includes("baseline"));
|
||||
const packageNames = platforms.map((p) => p.packageName);
|
||||
const packageDirs = platforms.map((p) => p.packageDir);
|
||||
|
||||
// then
|
||||
expect(baselinePlatforms.length).toBe(4);
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("linux-x64-musl-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("darwin-x64-baseline");
|
||||
expect(baselinePlatforms.map((p) => p.dir)).toContain("windows-x64-baseline");
|
||||
expect(packageDirs).toEqual(packageNames);
|
||||
expect(packageDirs).toContain("oh-my-opencode-linux-x64-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-linux-x64-musl-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-darwin-x64-baseline");
|
||||
expect(packageDirs).toContain("oh-my-opencode-windows-x64-baseline");
|
||||
});
|
||||
|
||||
it("has correct binary names for baseline platforms", async () => {
|
||||
// given
|
||||
const module = await import("./build-binaries.ts");
|
||||
const platforms = (module as { PLATFORMS: { dir: string; target: string; binary: string }[] }).PLATFORMS;
|
||||
const platforms = (module as { PLATFORMS: { packageDir: string; target: string; binary: string }[] }).PLATFORMS;
|
||||
|
||||
// when
|
||||
const windowsBaseline = platforms.find((p) => p.target === "bun-windows-x64-baseline");
|
||||
|
||||
+15
-13
@@ -7,30 +7,32 @@ import { existsSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
interface PlatformTarget {
|
||||
dir: string;
|
||||
platform: string;
|
||||
packageName: string;
|
||||
packageDir: string;
|
||||
target: string;
|
||||
binary: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export const PLATFORMS: PlatformTarget[] = [
|
||||
{ dir: "darwin-arm64", target: "bun-darwin-arm64", binary: "oh-my-opencode", description: "macOS ARM64" },
|
||||
{ dir: "darwin-x64", target: "bun-darwin-x64", binary: "oh-my-opencode", description: "macOS x64" },
|
||||
{ dir: "darwin-x64-baseline", target: "bun-darwin-x64-baseline", binary: "oh-my-opencode", description: "macOS x64 (no AVX2)" },
|
||||
{ dir: "linux-x64", target: "bun-linux-x64", binary: "oh-my-opencode", description: "Linux x64 (glibc)" },
|
||||
{ dir: "linux-x64-baseline", target: "bun-linux-x64-baseline", binary: "oh-my-opencode", description: "Linux x64 (glibc, no AVX2)" },
|
||||
{ dir: "linux-arm64", target: "bun-linux-arm64", binary: "oh-my-opencode", description: "Linux ARM64 (glibc)" },
|
||||
{ dir: "linux-x64-musl", target: "bun-linux-x64-musl", binary: "oh-my-opencode", description: "Linux x64 (musl)" },
|
||||
{ dir: "linux-x64-musl-baseline", target: "bun-linux-x64-musl-baseline", binary: "oh-my-opencode", description: "Linux x64 (musl, no AVX2)" },
|
||||
{ dir: "linux-arm64-musl", target: "bun-linux-arm64-musl", binary: "oh-my-opencode", description: "Linux ARM64 (musl)" },
|
||||
{ dir: "windows-x64", target: "bun-windows-x64", binary: "oh-my-opencode.exe", description: "Windows x64" },
|
||||
{ dir: "windows-x64-baseline", target: "bun-windows-x64-baseline", binary: "oh-my-opencode.exe", description: "Windows x64 (no AVX2)" },
|
||||
{ platform: "darwin-arm64", packageName: "oh-my-opencode-darwin-arm64", packageDir: "oh-my-opencode-darwin-arm64", target: "bun-darwin-arm64", binary: "oh-my-opencode", description: "macOS ARM64" },
|
||||
{ platform: "darwin-x64", packageName: "oh-my-opencode-darwin-x64", packageDir: "oh-my-opencode-darwin-x64", target: "bun-darwin-x64", binary: "oh-my-opencode", description: "macOS x64" },
|
||||
{ platform: "darwin-x64-baseline", packageName: "oh-my-opencode-darwin-x64-baseline", packageDir: "oh-my-opencode-darwin-x64-baseline", target: "bun-darwin-x64-baseline", binary: "oh-my-opencode", description: "macOS x64 (no AVX2)" },
|
||||
{ platform: "linux-x64", packageName: "oh-my-opencode-linux-x64", packageDir: "oh-my-opencode-linux-x64", target: "bun-linux-x64", binary: "oh-my-opencode", description: "Linux x64 (glibc)" },
|
||||
{ platform: "linux-x64-baseline", packageName: "oh-my-opencode-linux-x64-baseline", packageDir: "oh-my-opencode-linux-x64-baseline", target: "bun-linux-x64-baseline", binary: "oh-my-opencode", description: "Linux x64 (glibc, no AVX2)" },
|
||||
{ platform: "linux-arm64", packageName: "oh-my-opencode-linux-arm64", packageDir: "oh-my-opencode-linux-arm64", target: "bun-linux-arm64", binary: "oh-my-opencode", description: "Linux ARM64 (glibc)" },
|
||||
{ platform: "linux-x64-musl", packageName: "oh-my-opencode-linux-x64-musl", packageDir: "oh-my-opencode-linux-x64-musl", target: "bun-linux-x64-musl", binary: "oh-my-opencode", description: "Linux x64 (musl)" },
|
||||
{ platform: "linux-x64-musl-baseline", packageName: "oh-my-opencode-linux-x64-musl-baseline", packageDir: "oh-my-opencode-linux-x64-musl-baseline", target: "bun-linux-x64-musl-baseline", binary: "oh-my-opencode", description: "Linux x64 (musl, no AVX2)" },
|
||||
{ platform: "linux-arm64-musl", packageName: "oh-my-opencode-linux-arm64-musl", packageDir: "oh-my-opencode-linux-arm64-musl", target: "bun-linux-arm64-musl", binary: "oh-my-opencode", description: "Linux ARM64 (musl)" },
|
||||
{ platform: "windows-x64", packageName: "oh-my-opencode-windows-x64", packageDir: "oh-my-opencode-windows-x64", target: "bun-windows-x64", binary: "oh-my-opencode.exe", description: "Windows x64" },
|
||||
{ platform: "windows-x64-baseline", packageName: "oh-my-opencode-windows-x64-baseline", packageDir: "oh-my-opencode-windows-x64-baseline", target: "bun-windows-x64-baseline", binary: "oh-my-opencode.exe", description: "Windows x64 (no AVX2)" },
|
||||
];
|
||||
|
||||
const ENTRY_POINT = "src/cli/index.ts";
|
||||
|
||||
async function buildPlatform(platform: PlatformTarget): Promise<boolean> {
|
||||
const outfile = join("packages", platform.dir, "bin", platform.binary);
|
||||
const outfile = join("packages", platform.packageDir, "bin", platform.binary);
|
||||
|
||||
console.log(`\n📦 Building ${platform.description}...`);
|
||||
console.log(` Target: ${platform.target}`);
|
||||
|
||||
+23
-14
@@ -10,15 +10,24 @@ const versionOverride = process.env.VERSION
|
||||
const republishMode = process.env.REPUBLISH === "true"
|
||||
const prepareOnly = process.argv.includes("--prepare-only")
|
||||
|
||||
const PLATFORM_PACKAGES = [
|
||||
const PLATFORM_PACKAGE_IDS = [
|
||||
"darwin-arm64",
|
||||
"darwin-x64",
|
||||
"darwin-x64-baseline",
|
||||
"linux-x64",
|
||||
"linux-x64-baseline",
|
||||
"linux-arm64",
|
||||
"linux-x64-musl",
|
||||
"linux-x64-musl-baseline",
|
||||
"linux-arm64-musl",
|
||||
"windows-x64",
|
||||
]
|
||||
] as const
|
||||
|
||||
const PLATFORM_PACKAGES = PLATFORM_PACKAGE_IDS.map((platform) => ({
|
||||
platform,
|
||||
packageName: `${PACKAGE_NAME}-${platform}`,
|
||||
packageDir: `${PACKAGE_NAME}-${platform}`,
|
||||
}))
|
||||
|
||||
console.log("=== Publishing oh-my-opencode (multi-package) ===\n")
|
||||
|
||||
@@ -65,8 +74,8 @@ async function updateAllPackageVersions(newVersion: string): Promise<void> {
|
||||
|
||||
// Update optionalDependencies versions in main package.json
|
||||
let mainPkg = await Bun.file(mainPkgPath).text()
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
const pkgName = `oh-my-opencode-${platform}`
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
const pkgName = platformPackage.packageName
|
||||
mainPkg = mainPkg.replace(
|
||||
new RegExp(`"${pkgName}": "[^"]+"`),
|
||||
`"${pkgName}": "${newVersion}"`
|
||||
@@ -75,8 +84,8 @@ async function updateAllPackageVersions(newVersion: string): Promise<void> {
|
||||
await Bun.write(mainPkgPath, mainPkg)
|
||||
|
||||
// Update each platform package.json
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
const pkgPath = new URL(`../packages/${platform}/package.json`, import.meta.url).pathname
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
const pkgPath = new URL(`../packages/${platformPackage.packageDir}/package.json`, import.meta.url).pathname
|
||||
if (existsSync(pkgPath)) {
|
||||
await updatePackageVersion(pkgPath, newVersion)
|
||||
} else {
|
||||
@@ -266,16 +275,16 @@ async function publishAllPackages(version: string): Promise<void> {
|
||||
const batchNum = Math.floor(i / BATCH_SIZE) + 1
|
||||
const totalBatches = Math.ceil(PLATFORM_PACKAGES.length / BATCH_SIZE)
|
||||
|
||||
console.log(`\n Batch ${batchNum}/${totalBatches}: ${batch.join(", ")}`)
|
||||
console.log(`\n Batch ${batchNum}/${totalBatches}: ${batch.map((platformPackage) => platformPackage.platform).join(", ")}`)
|
||||
|
||||
const publishPromises = batch.map(async (platform) => {
|
||||
const pkgDir = join(process.cwd(), "packages", platform)
|
||||
const pkgName = `oh-my-opencode-${platform}`
|
||||
const publishPromises = batch.map(async (platformPackage) => {
|
||||
const pkgDir = join(process.cwd(), "packages", platformPackage.packageDir)
|
||||
const pkgName = platformPackage.packageName
|
||||
|
||||
console.log(` Starting ${pkgName}...`)
|
||||
const result = await publishPackage(pkgDir, distTag, false, pkgName, version)
|
||||
|
||||
return { platform, pkgName, result }
|
||||
return { platform: platformPackage.platform, pkgName, result }
|
||||
})
|
||||
|
||||
const results = await Promise.all(publishPromises)
|
||||
@@ -338,8 +347,8 @@ async function gitTagAndRelease(newVersion: string, notes: string[]): Promise<vo
|
||||
|
||||
// Add all package.json files
|
||||
await $`git add package.json assets/oh-my-opencode.schema.json`
|
||||
for (const platform of PLATFORM_PACKAGES) {
|
||||
await $`git add packages/${platform}/package.json`.nothrow()
|
||||
for (const platformPackage of PLATFORM_PACKAGES) {
|
||||
await $`git add packages/${platformPackage.packageDir}/package.json`.nothrow()
|
||||
}
|
||||
|
||||
const hasStagedChanges = await $`git diff --cached --quiet`.nothrow()
|
||||
@@ -417,7 +426,7 @@ async function main() {
|
||||
await publishAllPackages(newVersion)
|
||||
await gitTagAndRelease(newVersion, notes)
|
||||
|
||||
console.log(`\n=== Successfully published ${PACKAGE_NAME}@${newVersion} (8 packages) ===`)
|
||||
console.log(`\n=== Successfully published ${PACKAGE_NAME}@${newVersion} (${PLATFORM_PACKAGES.length + 1} packages) ===`)
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user