Repository navigation
150 lines (137 loc) · 5.69 KB
/
Copy pathbuild-ghosttykit.yml
File metadata and controls
150 lines (137 loc) · 5.69 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Build GhosttyKit
on:
push:
branches:
- main
paths:
# Bare "ghostty" is required to match submodule POINTER bumps; the glob
# only matches diffs inside the submodule tree (see ci.yml note).
- "ghostty"
- "ghostty/**"
- ".gitmodules"
- "scripts/ensure-ghosttykit.sh"
- "scripts/required-zig-version.sh"
- "scripts/download-prebuilt-ghosttykit.sh"
- "scripts/install-zig.sh"
- "scripts/zig-macos-aarch64.sha256"
- ".github/workflows/build-ghosttykit.yml"
pull_request:
paths:
# Bare "ghostty" is required to match submodule POINTER bumps; the glob
# only matches diffs inside the submodule tree (see ci.yml note).
- "ghostty"
- "ghostty/**"
- ".gitmodules"
- "scripts/ensure-ghosttykit.sh"
- "scripts/required-zig-version.sh"
- "scripts/download-prebuilt-ghosttykit.sh"
- "scripts/install-zig.sh"
- "scripts/zig-macos-aarch64.sha256"
- ".github/workflows/build-ghosttykit.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-ghosttykit:
runs-on: macos-15
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Get ghostty SHA
id: ghostty-sha
run: |
SHA=$(git -C ghostty rev-parse HEAD)
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
echo "Ghostty SHA: $SHA"
- name: Check if xcframework release already exists
id: check-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="xcframework-${{ steps.ghostty-sha.outputs.sha }}"
if gh release view "$TAG" --repo darkroomengineering/ghostty >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
echo "Release $TAG already exists, skipping build"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "Release $TAG not found, will build"
fi
- name: Select Xcode
if: steps.check-release.outputs.exists == 'false'
run: |
set -euo pipefail
if [ -d "/Applications/Xcode.app/Contents/Developer" ]; then
XCODE_DIR="/Applications/Xcode.app/Contents/Developer"
else
XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | head -n 1 || true)"
if [ -n "$XCODE_APP" ]; then
XCODE_DIR="$XCODE_APP/Contents/Developer"
else
echo "No Xcode.app found under /Applications" >&2
exit 1
fi
fi
echo "DEVELOPER_DIR=$XCODE_DIR" >> "$GITHUB_ENV"
export DEVELOPER_DIR="$XCODE_DIR"
xcodebuild -version
- name: Resolve zig version
if: steps.check-release.outputs.exists == 'false'
id: zig-version
run: printf 'version=%s\n' "$(./scripts/required-zig-version.sh)" >> "$GITHUB_OUTPUT"
# install-zig.sh re-checks the tarball against scripts/zig-macos-aarch64.sha256
# on every run, so a cache hit never skips the checksum.
- name: Cache zig toolchain tarball
if: steps.check-release.outputs.exists == 'false'
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ~/.cache/programa-zig-dist
key: zig-dist-macos-arm64-${{ steps.zig-version.outputs.version }}
- name: Cache Zig packages
if: steps.check-release.outputs.exists == 'false'
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ~/.cache/zig
key: zig-packages-${{ hashFiles('ghostty/build.zig.zon', 'ghostty/build.zig.zon.json') }}
restore-keys: zig-packages-
- name: Build GhosttyKit.xcframework
if: steps.check-release.outputs.exists == 'false'
run: |
set -euo pipefail
./scripts/install-zig.sh
cd ghostty && zig build -Demit-xcframework=true -Demit-macos-app=false -Dxcframework-target=native -Doptimize=ReleaseFast
- name: Package xcframework
if: steps.check-release.outputs.exists == 'false'
run: |
set -euo pipefail
rm -rf GhosttyKit.xcframework
cp -R ghostty/macos/GhosttyKit.xcframework GhosttyKit.xcframework
# Ghostty has used several archive names across revisions.
ARCHIVE="$(find GhosttyKit.xcframework -type f \( -name 'libghostty.a' -o -name 'libghostty-fat.a' -o -name 'libghostty-internal.a' -o -name 'libghostty-internal-fat.a' \) -print -quit)"
if [ -z "$ARCHIVE" ]; then
echo "GhosttyKit.xcframework does not contain a supported macOS libghostty archive" >&2
exit 1
fi
./scripts/verify-release-architectures.sh "$ARCHIVE"
tar czf GhosttyKit.xcframework.tar.gz GhosttyKit.xcframework
- name: Upload xcframework release
if: steps.check-release.outputs.exists == 'false'
env:
GH_TOKEN: ${{ secrets.GHOSTTY_RELEASE_TOKEN }}
run: |
set -euo pipefail
if [ -z "${GH_TOKEN:-}" ]; then
echo "GHOSTTY_RELEASE_TOKEN not available (fork PR), skipping upload"
exit 0
fi
TAG="xcframework-${{ steps.ghostty-sha.outputs.sha }}"
gh release create "$TAG" \
--repo darkroomengineering/ghostty \
--title "GhosttyKit xcframework (${{ steps.ghostty-sha.outputs.sha }})" \
--notes "Pre-built GhosttyKit.xcframework for commit ${{ steps.ghostty-sha.outputs.sha }}" \
GhosttyKit.xcframework.tar.gz
echo "Published release $TAG"