-
Notifications
You must be signed in to change notification settings - Fork 161
271 lines (226 loc) · 8.39 KB
/
sync.yml
File metadata and controls
271 lines (226 loc) · 8.39 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Sync Upstream & Patch
on:
schedule:
- cron: "0 8 * * *" # Daily 08:00 UTC
workflow_dispatch:
inputs:
force:
description: "Force sync even without version change"
type: boolean
default: false
env:
NODE_VERSION: "24"
jobs:
check:
runs-on: ubuntu-latest
outputs:
has_update: ${{ steps.detect.outputs.has_update }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Check upstream versions
id: detect
run: |
set +e
node scripts/check-update.js --json --force 2>&1
exit_code=$?
set -e
if [ "${{ inputs.force }}" = "true" ]; then
echo "has_update=true" >> "$GITHUB_OUTPUT"
elif [ $exit_code -eq 0 ]; then
echo "has_update=true" >> "$GITHUB_OUTPUT"
else
echo "has_update=false" >> "$GITHUB_OUTPUT"
echo "No upstream update detected."
fi
# ──────────────────────────────────────────────
# Each platform: sync + patch + build in one job
# (src/ is gitignored, so it must be generated per-runner)
# ──────────────────────────────────────────────
build-mac:
needs: check
if: needs.check.outputs.has_update == 'true'
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
arch: [x64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Install dependencies
run: |
npm ci
- name: Install tools
run: |
brew install --quiet sevenzip
- name: Sync upstream (macOS only)
run: node scripts/sync-upstream.js --force --skip-win
- name: Patch
run: node scripts/patch-all.js mac-${{ matrix.arch }}
- name: Build
run: npm run build:mac-${{ matrix.arch }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: Codex-macOS-${{ matrix.arch }}
path: out/*.dmg
if-no-files-found: error
build-windows:
needs: check
if: needs.check.outputs.has_update == 'true'
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Install dependencies
run: |
npm ci
- name: Install tools
run: |
choco install 7zip -y
- name: Add 7zz alias
run: |
Copy-Item "C:\Program Files\7-Zip\7z.exe" "C:\Program Files\7-Zip\7zz.exe"
echo "C:\Program Files\7-Zip" | Out-File -Append -Encoding utf8 $env:GITHUB_PATH
- name: Sync upstream (Windows only)
run: node scripts/sync-upstream.js --force --skip-mac
- name: Patch
run: node scripts/patch-all.js win
- name: Build
run: npm run build:win-x64
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: Codex-Windows-x64
path: out/*.zip
if-no-files-found: error
build-linux:
needs: check
if: needs.check.outputs.has_update == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [x64, arm64]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: npm
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y rpm fakeroot dpkg 7zip
- name: Install dependencies
run: |
npm ci
- name: Sync upstream (macOS ZIP for unix, skip Windows)
run: node scripts/sync-upstream.js --force --skip-win
- name: Patch
run: node scripts/patch-all.js mac-${{ matrix.arch }}
- name: Build
run: npm run build:linux-${{ matrix.arch }}
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: Codex-Linux-${{ matrix.arch }}
path: |
out/make/deb/**/*.deb
out/make/rpm/**/*.rpm
out/make/zip/**/*.zip
if-no-files-found: error
# ──────────────────────────────────────────────
# Bump version + tag + release
# ──────────────────────────────────────────────
release:
needs: [build-mac, build-windows, build-linux]
if: always() && needs.check.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci
- name: Get upstream version and tag
id: version
run: |
RESULT=$(node scripts/check-update.js --json --force)
MAC_ARM64=$(echo "$RESULT" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const j=JSON.parse(d);console.log(j.platforms?.['macOS-arm64']?.version||'')}catch{console.log('')}})")
MAC_X64=$(echo "$RESULT" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const j=JSON.parse(d);console.log(j.platforms?.['macOS-x64']?.version||'')}catch{console.log('')}})")
WIN_VER=$(echo "$RESULT" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{try{const j=JSON.parse(d);console.log(j.platforms?.Windows?.version||'')}catch{console.log('')}})")
VERSION="${MAC_ARM64:-${MAC_X64:-$WIN_VER}}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "mac_arm64=$MAC_ARM64" >> "$GITHUB_OUTPUT"
echo "mac_x64=$MAC_X64" >> "$GITHUB_OUTPUT"
echo "win_version=$WIN_VER" >> "$GITHUB_OUTPUT"
if [ -z "$VERSION" ]; then echo "No version detected"; exit 0; fi
node -e "
const fs=require('fs'), p=JSON.parse(fs.readFileSync('package.json','utf8'));
p.version='$VERSION';
fs.writeFileSync('package.json', JSON.stringify(p,null,2)+'\n');
"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json
git diff --cached --quiet && echo "No version change" && exit 0
git commit -m "Bump version to ${VERSION}"
git tag -a "v${VERSION}" -m "Codex ${VERSION}"
git push origin HEAD --tags
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Display structure
run: ls -lhR artifacts/
- name: Create Release
if: steps.version.outputs.version != ''
uses: softprops/action-gh-release@v3
with:
tag_name: v${{ steps.version.outputs.version }}
name: Codex ${{ steps.version.outputs.version }}
body: |
## Upstream Versions
| Platform | Version |
|----------|---------|
| macOS arm64 | `${{ steps.version.outputs.mac_arm64 || 'N/A' }}` |
| macOS x64 | `${{ steps.version.outputs.mac_x64 || 'N/A' }}` |
| Windows x64 | `${{ steps.version.outputs.win_version || 'N/A' }}` |
| Linux | uses macOS ASAR |
files: |
artifacts/**/*.dmg
artifacts/**/*.zip
artifacts/**/*.deb
artifacts/**/*.rpm
artifacts/**/*.exe
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}