-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathbuild-macos-local.sh
More file actions
executable file
·93 lines (74 loc) · 2.51 KB
/
Copy pathbuild-macos-local.sh
File metadata and controls
executable file
·93 lines (74 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env bash
set -euo pipefail
VERSION_TAG="$1"
DIST_DIR="dist/bin"
IDEA_CODEX_BIN_DIR="$2"
PACKAGE_JSON="package.json"
PACKAGE_JSON_BAK="$(mktemp)"
if [[ -z "${VERSION_TAG}" || -z "${IDEA_CODEX_BIN_DIR}" ]]; then
echo "Usage: $0 <version-tag> <idea-codex-bin-dir>"
exit 1
fi
cp "$PACKAGE_JSON" "$PACKAGE_JSON_BAK"
cleanup() {
cp "$PACKAGE_JSON_BAK" "$PACKAGE_JSON"
rm -f "$PACKAGE_JSON_BAK"
}
trap cleanup EXIT
mkdir -p "$DIST_DIR"
# Keep CI-compatible artifact names in dist/bin.
rm -f \
"$DIST_DIR/codex-acp-x64-darwin" \
"$DIST_DIR/codex-acp-arm64-darwin" \
"$DIST_DIR/codex-acp-x64-darwin.zip" \
"$DIST_DIR/codex-acp-arm64-darwin.zip"
echo "Temporarily setting package version to: ${VERSION_TAG}"
perl -i -pe 's/"version":\s*"[^"]+"/"version": "'"${VERSION_TAG}"'"/' "$PACKAGE_JSON"
echo "Building macOS binaries..."
bun build src/index.ts --minify --sourcemap --compile --target=bun-darwin-x64-baseline --outfile dist/bin/codex-acp-x64-darwin
bun build src/index.ts --minify --sourcemap --compile --target=bun-darwin-arm64 --outfile dist/bin/codex-acp-arm64-darwin
echo "Packaging artifacts in GitHub Actions format..."
(
cd "$DIST_DIR"
zip -q codex-acp-x64-darwin.zip codex-acp-x64-darwin
zip -q codex-acp-arm64-darwin.zip codex-acp-arm64-darwin
)
X64_VERSION="$("$DIST_DIR/codex-acp-x64-darwin" --version | tail -n 1)"
ARM64_VERSION="$("$DIST_DIR/codex-acp-arm64-darwin" --version | tail -n 1)"
if [[ "$X64_VERSION" != *" ${VERSION_TAG}" ]]; then
echo "Version check failed for x64: $X64_VERSION"
exit 1
fi
if [[ "$ARM64_VERSION" != *" ${VERSION_TAG}" ]]; then
echo "Version check failed for arm64: $ARM64_VERSION"
exit 1
fi
echo "Done. Artifacts:"
ls -lh \
"$DIST_DIR/codex-acp-x64-darwin" \
"$DIST_DIR/codex-acp-arm64-darwin" \
"$DIST_DIR/codex-acp-x64-darwin.zip" \
"$DIST_DIR/codex-acp-arm64-darwin.zip"
echo "Copying local macOS binaries to IntelliJ dev Codex bin dir..."
COPIED_ARTIFACTS=()
for artifact in \
"codex-acp-x64-darwin" \
"codex-acp-arm64-darwin" \
"codex-acp-x64-darwin.zip" \
"codex-acp-arm64-darwin.zip"; do
source_path="$DIST_DIR/$artifact"
target_path="$IDEA_CODEX_BIN_DIR/$artifact"
if [[ -e "$target_path" ]]; then
cp -f "$source_path" "$target_path"
COPIED_ARTIFACTS+=("$target_path")
else
echo "Skipping missing target: $target_path"
fi
done
echo "Copied artifacts:"
if [[ ${#COPIED_ARTIFACTS[@]} -gt 0 ]]; then
ls -lh "${COPIED_ARTIFACTS[@]}"
else
echo "No existing target artifacts were updated."
fi
echo "Embedded version: ${VERSION_TAG}"