Compare commits
3 commits
dev
...
brendan/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a638728201 |
||
|
|
28cb8efa4b |
||
|
|
b0bd728275 |
3 changed files with 133 additions and 10 deletions
74
.github/workflows/publish.yml
vendored
74
.github/workflows/publish.yml
vendored
|
|
@ -67,7 +67,7 @@ jobs:
|
||||||
tag: ${{ steps.version.outputs.tag }}
|
tag: ${{ steps.version.outputs.tag }}
|
||||||
repo: ${{ steps.version.outputs.repo }}
|
repo: ${{ steps.version.outputs.repo }}
|
||||||
|
|
||||||
build-cli:
|
build-cli-linux-win:
|
||||||
needs: version
|
needs: version
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
if: github.repository == 'anomalyco/opencode'
|
if: github.repository == 'anomalyco/opencode'
|
||||||
|
|
@ -94,17 +94,74 @@ jobs:
|
||||||
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
||||||
GH_REPO: ${{ needs.version.outputs.repo }}
|
GH_REPO: ${{ needs.version.outputs.repo }}
|
||||||
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
||||||
|
OPENCODE_BUILD_OS: linux,win32
|
||||||
|
OPENCODE_SKIP_RELEASE_UPLOAD: "1"
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: opencode-cli
|
name: opencode-cli-linux-win
|
||||||
|
path: packages/opencode/dist
|
||||||
|
|
||||||
|
build-cli-darwin:
|
||||||
|
needs: version
|
||||||
|
runs-on: macos-latest
|
||||||
|
if: github.repository == 'anomalyco/opencode'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: ./.github/actions/setup-bun
|
||||||
|
|
||||||
|
- name: Setup git committer
|
||||||
|
id: committer
|
||||||
|
uses: ./.github/actions/setup-git-committer
|
||||||
|
with:
|
||||||
|
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
|
||||||
|
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||||
|
|
||||||
|
- uses: apple-actions/import-codesign-certs@v2
|
||||||
|
with:
|
||||||
|
keychain: build
|
||||||
|
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Resolve signing identity
|
||||||
|
run: |
|
||||||
|
CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
|
||||||
|
CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
|
||||||
|
if [ -z "$CERT_ID" ]; then
|
||||||
|
echo "Developer ID Application identity not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: build
|
||||||
|
run: |
|
||||||
|
./packages/opencode/script/build.ts
|
||||||
|
env:
|
||||||
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
||||||
|
GH_REPO: ${{ needs.version.outputs.repo }}
|
||||||
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
||||||
|
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
|
||||||
|
OPENCODE_BUILD_OS: darwin
|
||||||
|
OPENCODE_SKIP_RELEASE_UPLOAD: "1"
|
||||||
|
|
||||||
|
- name: Verify darwin signatures
|
||||||
|
run: |
|
||||||
|
for file in packages/opencode/dist/opencode-darwin-*/bin/opencode; do
|
||||||
|
codesign -vvv --verify "$file"
|
||||||
|
done
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: opencode-cli-darwin
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
outputs:
|
|
||||||
version: ${{ needs.version.outputs.version }}
|
|
||||||
|
|
||||||
build-tauri:
|
build-tauri:
|
||||||
needs:
|
needs:
|
||||||
- build-cli
|
|
||||||
- version
|
- version
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -248,7 +305,6 @@ jobs:
|
||||||
|
|
||||||
build-electron:
|
build-electron:
|
||||||
needs:
|
needs:
|
||||||
- build-cli
|
|
||||||
- version
|
- version
|
||||||
continue-on-error: false
|
continue-on-error: false
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -372,7 +428,8 @@ jobs:
|
||||||
publish:
|
publish:
|
||||||
needs:
|
needs:
|
||||||
- version
|
- version
|
||||||
- build-cli
|
- build-cli-darwin
|
||||||
|
- build-cli-linux-win
|
||||||
- build-tauri
|
- build-tauri
|
||||||
- build-electron
|
- build-electron
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
|
|
@ -408,8 +465,9 @@ jobs:
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: opencode-cli
|
pattern: opencode-cli-*
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@v4
|
||||||
if: needs.version.outputs.release
|
if: needs.version.outputs.release
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@ console.log(`Loaded ${migrations.length} migrations`)
|
||||||
const singleFlag = process.argv.includes("--single")
|
const singleFlag = process.argv.includes("--single")
|
||||||
const baselineFlag = process.argv.includes("--baseline")
|
const baselineFlag = process.argv.includes("--baseline")
|
||||||
const skipInstall = process.argv.includes("--skip-install")
|
const skipInstall = process.argv.includes("--skip-install")
|
||||||
|
const skipUpload = process.argv.includes("--skip-release-upload") || process.env.OPENCODE_SKIP_RELEASE_UPLOAD === "1"
|
||||||
|
const sign = process.env.APPLE_SIGNING_IDENTITY
|
||||||
|
const entitlements = process.env.OPENCODE_CODESIGN_ENTITLEMENTS || path.join(dir, "script/entitlements.plist")
|
||||||
|
const raw = process.env.OPENCODE_BUILD_OS?.trim()
|
||||||
|
|
||||||
const allTargets: {
|
const allTargets: {
|
||||||
os: string
|
os: string
|
||||||
|
|
@ -148,6 +152,31 @@ const targets = singleFlag
|
||||||
})
|
})
|
||||||
: allTargets
|
: allTargets
|
||||||
|
|
||||||
|
const os = raw
|
||||||
|
? Array.from(
|
||||||
|
new Set(
|
||||||
|
raw
|
||||||
|
.split(",")
|
||||||
|
.map((x) => x.trim())
|
||||||
|
.filter(Boolean),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
if (os) {
|
||||||
|
const set = new Set(allTargets.map((item) => item.os))
|
||||||
|
const bad = os.filter((item) => !set.has(item))
|
||||||
|
if (bad.length > 0) {
|
||||||
|
throw new Error(`Invalid OPENCODE_BUILD_OS value: ${bad.join(", ")}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const list = os ? targets.filter((item) => os.includes(item.os)) : targets
|
||||||
|
|
||||||
|
if (list.length === 0) {
|
||||||
|
throw new Error("No build targets selected")
|
||||||
|
}
|
||||||
|
|
||||||
await $`rm -rf dist`
|
await $`rm -rf dist`
|
||||||
|
|
||||||
const binaries: Record<string, string> = {}
|
const binaries: Record<string, string> = {}
|
||||||
|
|
@ -155,7 +184,7 @@ if (!skipInstall) {
|
||||||
await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}`
|
await $`bun install --os="*" --cpu="*" @opentui/core@${pkg.dependencies["@opentui/core"]}`
|
||||||
await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}`
|
await $`bun install --os="*" --cpu="*" @parcel/watcher@${pkg.dependencies["@parcel/watcher"]}`
|
||||||
}
|
}
|
||||||
for (const item of targets) {
|
for (const item of list) {
|
||||||
const name = [
|
const name = [
|
||||||
pkg.name,
|
pkg.name,
|
||||||
// changing to win32 flags npm for some reason
|
// changing to win32 flags npm for some reason
|
||||||
|
|
@ -203,6 +232,24 @@ for (const item of targets) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (item.os === "darwin") {
|
||||||
|
if (Script.release && process.platform !== "darwin") {
|
||||||
|
throw new Error("darwin release binaries must be built on macOS runners")
|
||||||
|
}
|
||||||
|
if (Script.release && !sign) {
|
||||||
|
throw new Error("APPLE_SIGNING_IDENTITY is required for darwin release binaries")
|
||||||
|
}
|
||||||
|
if (process.platform === "darwin" && sign) {
|
||||||
|
if (!fs.existsSync(entitlements)) {
|
||||||
|
throw new Error(`Codesign entitlements file not found: ${entitlements}`)
|
||||||
|
}
|
||||||
|
const file = `dist/${name}/bin/opencode`
|
||||||
|
console.log(`codesigning ${name}`)
|
||||||
|
await $`codesign --entitlements ${entitlements} -vvvv --deep --sign ${sign} ${file} --force`
|
||||||
|
await $`codesign -vvv --verify ${file}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Smoke test: only run if binary is for current platform
|
// Smoke test: only run if binary is for current platform
|
||||||
if (item.os === process.platform && item.arch === process.arch && !item.abi) {
|
if (item.os === process.platform && item.arch === process.arch && !item.abi) {
|
||||||
const binaryPath = `dist/${name}/bin/opencode`
|
const binaryPath = `dist/${name}/bin/opencode`
|
||||||
|
|
@ -240,7 +287,9 @@ if (Script.release) {
|
||||||
await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`)
|
await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!skipUpload) {
|
||||||
await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}`
|
await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { binaries }
|
export { binaries }
|
||||||
|
|
|
||||||
16
packages/opencode/script/entitlements.plist
Normal file
16
packages/opencode/script/entitlements.plist
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>com.apple.security.cs.allow-jit</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.disable-executable-page-protection</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.security.cs.disable-library-validation</key>
|
||||||
|
<true/>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue