mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
The Linux arm64 Package step took about 11 minutes on releases: fpm compressed the deb with single-threaded xz -3 (5.7 min) and the rpm with xz -9 (4.6 min). - build-electron sets XZ_DEFAULTS=-T0, so the deb compresses on every CPU at the same level (+0.6% size). - The prod rpm uses xz -3 instead of -9 (+17% size, the same size as the deb). On the v1.19.3 arm64 payload in an Ubuntu 24.04 arm64 container (4 CPUs) this takes Package from 113 s to 37 s.
828 lines
34 KiB
YAML
828 lines
34 KiB
YAML
name: publish
|
|
run-name: "${{ format('release {0}', inputs.bump) }}"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
- beta
|
|
workflow_dispatch:
|
|
inputs:
|
|
bump:
|
|
description: "Bump major, minor, or patch"
|
|
required: false
|
|
type: choice
|
|
options:
|
|
- major
|
|
- minor
|
|
- patch
|
|
version:
|
|
description: "Override version (optional)"
|
|
required: false
|
|
type: string
|
|
release_notes:
|
|
description: "Reviewed V2 release notes for CHANGELOG.md and the Discord announcement (optional)"
|
|
required: false
|
|
type: string
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ (github.ref_name == 'dev' && (inputs.version || inputs.bump) && 'release') || inputs.version || inputs.bump }}
|
|
|
|
permissions:
|
|
id-token: write
|
|
contents: write
|
|
packages: write
|
|
# script/wait-for-artifact.ts reads this run's artifacts and jobs.
|
|
actions: read
|
|
|
|
env:
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'dev' && !inputs.bump && !inputs.version && 'dev') || '' }}
|
|
|
|
jobs:
|
|
version:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
if: github.repository == 'anomalyco/opencode'
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- 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 }}
|
|
|
|
- id: version
|
|
run: |
|
|
./script/version.ts
|
|
env:
|
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
|
OPENCODE_BUMP: ${{ inputs.bump }}
|
|
OPENCODE_VERSION: ${{ inputs.version }}
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
release: ${{ steps.version.outputs.release }}
|
|
tag: ${{ steps.version.outputs.tag }}
|
|
|
|
# Built once for every build-cli and build-node-cli leg.
|
|
build-app-archive:
|
|
needs: version
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 30
|
|
if: github.repository == 'anomalyco/opencode'
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- uses: ./.github/actions/setup-bun
|
|
|
|
- name: Build app archive
|
|
run: bun packages/cli/script/build-node.ts --app-archive-only --app-archive=.cache/app-archive.bin --skip-install
|
|
env:
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: opencode-app-archive
|
|
path: packages/cli/.cache/app-archive.bin
|
|
if-no-files-found: error
|
|
|
|
build-cli:
|
|
needs:
|
|
- version
|
|
- build-app-archive
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 30
|
|
if: github.repository == 'anomalyco/opencode'
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
target:
|
|
- darwin-arm64
|
|
- darwin-x64
|
|
- darwin-x64-baseline
|
|
- windows-arm64
|
|
- windows-x64
|
|
- windows-x64-baseline
|
|
- linux-arm64
|
|
- linux-x64
|
|
- linux-x64-baseline
|
|
- linux-arm64-musl
|
|
- linux-x64-musl
|
|
- linux-x64-baseline-musl
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
with:
|
|
fetch-tags: true
|
|
|
|
- uses: ./.github/actions/setup-bun
|
|
with:
|
|
bun-version: 1.4.2
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
name: opencode-app-archive
|
|
path: packages/cli/.cache
|
|
|
|
# build.ts fetches the Bun release through the REST API. An app token keeps that off the GITHUB_TOKEN budget the
|
|
# desktop jobs poll with; read-only because the build runs dependency install scripts.
|
|
- name: Create Bun download token
|
|
id: bun-token
|
|
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
|
|
with:
|
|
app-id: ${{ vars.OPENCODE_APP_ID }}
|
|
private-key: ${{ secrets.OPENCODE_APP_SECRET }}
|
|
owner: ${{ github.repository_owner }}
|
|
repositories: opencode
|
|
permission-contents: read
|
|
|
|
- name: Build CLI
|
|
run: ./packages/cli/script/build.ts --target=opencode-${{ matrix.target }} --app-archive=.cache/app-archive.bin
|
|
env:
|
|
BUN_COMPILE_RELEASE: bun-v1.4.2
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
|
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'dev' && inputs.release_notes) || '' }}
|
|
GH_REPO: ${{ github.repository }}
|
|
GH_TOKEN: ${{ steps.bun-token.outputs.token }}
|
|
|
|
# The artifact must hold this target alone: publish merges every CLI artifact into one dist.
|
|
- name: Check CLI output
|
|
run: |
|
|
actual=$(ls packages/cli/dist)
|
|
if [ "$actual" != "cli-${{ matrix.target }}" ]; then
|
|
echo "Expected only cli-${{ matrix.target }} in packages/cli/dist, found: $actual"
|
|
exit 1
|
|
fi
|
|
|
|
# The glob keeps the cli-<target>/ directory in the artifact.
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: cli-unsigned-${{ matrix.target }}
|
|
path: packages/cli/dist/cli-*
|
|
if-no-files-found: error
|
|
|
|
sign-cli-macos:
|
|
needs: build-cli
|
|
runs-on: macos-26
|
|
# Beta publishes only the desktop app, which signs the CLI it bundles.
|
|
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta'
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
|
|
with:
|
|
keychain: build
|
|
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
|
|
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
pattern: cli-unsigned-darwin-*
|
|
path: packages/cli/dist
|
|
merge-multiple: true
|
|
|
|
- name: Sign macOS CLI binaries
|
|
run: |
|
|
identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1)
|
|
if [ -z "$identity" ]; then
|
|
echo "Developer ID Application identity not found"
|
|
exit 1
|
|
fi
|
|
|
|
found=0
|
|
for file in packages/cli/dist/cli-darwin-*/bin/opencode; do
|
|
if [ ! -f "$file" ]; then
|
|
continue
|
|
fi
|
|
found=1
|
|
codesign \
|
|
--force \
|
|
--timestamp \
|
|
--options runtime \
|
|
--entitlements packages/cli/script/entitlements.plist \
|
|
--sign "$identity" \
|
|
"$file"
|
|
codesign --verify --deep --strict --verbose=4 "$file"
|
|
codesign --display --requirements - "$file"
|
|
done
|
|
|
|
if [ "$found" -eq 0 ]; then
|
|
echo "No macOS CLI binaries found"
|
|
exit 1
|
|
fi
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: cli-signed-darwin
|
|
path: packages/cli/dist/cli-darwin-*
|
|
if-no-files-found: error
|
|
|
|
build-node-cli:
|
|
needs:
|
|
- version
|
|
- build-app-archive
|
|
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta' && !(github.ref_name == 'dev' && (inputs.bump || inputs.version))
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
settings:
|
|
- target: linux-arm64
|
|
host: blacksmith-4vcpu-ubuntu-2404-arm
|
|
- target: linux-x64
|
|
host: blacksmith-4vcpu-ubuntu-2404
|
|
- target: darwin-arm64
|
|
host: macos-26
|
|
- target: windows-arm64
|
|
host: blacksmith-4vcpu-windows-2025
|
|
bun_install_flags: --cpu=*
|
|
- target: windows-x64
|
|
host: blacksmith-4vcpu-windows-2025
|
|
runs-on: ${{ matrix.settings.host }}
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- uses: ./.github/actions/setup-bun
|
|
with:
|
|
install-flags: ${{ matrix.settings.bun_install_flags }}
|
|
|
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "26.4.0"
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
name: opencode-app-archive
|
|
path: packages/cli/.cache
|
|
|
|
- name: Build
|
|
run: bun packages/cli/script/build-node.ts --target=${{ matrix.settings.target }} --skip-install --outdir=dist/node --app-archive=.cache/app-archive.bin
|
|
env:
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
|
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'dev' && inputs.release_notes) || '' }}
|
|
|
|
- name: Verify service lifecycle
|
|
if: matrix.settings.target != 'windows-arm64'
|
|
working-directory: packages/cli
|
|
run: bun run script/service-smoke.ts --node
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: opencode-node-cli-${{ matrix.settings.target }}
|
|
path: packages/cli/dist/node/cli-node-*
|
|
if-no-files-found: error
|
|
|
|
sign-cli-windows:
|
|
needs:
|
|
- build-cli
|
|
runs-on: blacksmith-4vcpu-windows-2025
|
|
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'dev'
|
|
env:
|
|
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
|
|
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
|
|
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
|
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
|
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
|
steps:
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
pattern: cli-unsigned-windows-*
|
|
path: packages/cli/dist
|
|
merge-multiple: true
|
|
|
|
- name: Azure login
|
|
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
|
with:
|
|
client-id: ${{ env.AZURE_CLIENT_ID }}
|
|
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
|
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
- uses: azure/artifact-signing-action@b443cf8ea4124818d2ea9f043cba29fc3ec47b16 # v1.2.0
|
|
with:
|
|
endpoint: ${{ env.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
|
signing-account-name: ${{ env.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
|
certificate-profile-name: ${{ env.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
|
files: |
|
|
${{ github.workspace }}\packages\cli\dist\cli-windows-arm64\bin\opencode.exe
|
|
${{ github.workspace }}\packages\cli\dist\cli-windows-x64\bin\opencode.exe
|
|
${{ github.workspace }}\packages\cli\dist\cli-windows-x64-baseline\bin\opencode.exe
|
|
exclude-environment-credential: true
|
|
exclude-workload-identity-credential: true
|
|
exclude-managed-identity-credential: true
|
|
exclude-shared-token-cache-credential: true
|
|
exclude-visual-studio-credential: true
|
|
exclude-visual-studio-code-credential: true
|
|
exclude-azure-cli-credential: false
|
|
exclude-azure-powershell-credential: true
|
|
exclude-azure-developer-cli-credential: true
|
|
exclude-interactive-browser-credential: true
|
|
|
|
- name: Verify Windows CLI signatures
|
|
shell: pwsh
|
|
run: |
|
|
$files = @(
|
|
"${{ github.workspace }}\packages\cli\dist\cli-windows-arm64\bin\opencode.exe",
|
|
"${{ github.workspace }}\packages\cli\dist\cli-windows-x64\bin\opencode.exe",
|
|
"${{ github.workspace }}\packages\cli\dist\cli-windows-x64-baseline\bin\opencode.exe"
|
|
)
|
|
|
|
foreach ($file in $files) {
|
|
$sig = Get-AuthenticodeSignature $file
|
|
if ($sig.Status -ne "Valid") {
|
|
throw "Invalid signature for ${file}: $($sig.Status)"
|
|
}
|
|
}
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: cli-signed-windows
|
|
path: packages/cli/dist/cli-windows-*
|
|
if-no-files-found: error
|
|
|
|
build-electron:
|
|
# Desktop packaging re-signs the bundled CLI on macOS and Windows, so it starts from the unsigned build.
|
|
# No build-cli need: it builds the app first and waits for its own CLI before Prepare.
|
|
needs:
|
|
- version
|
|
if: github.repository == 'anomalyco/opencode' && ((github.ref_name == 'dev' && needs.version.outputs.release != '') || github.ref_name == 'beta')
|
|
continue-on-error: false
|
|
env:
|
|
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
|
|
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
|
|
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
|
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
|
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
|
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
|
# fpm passes the deb's xz level in XZ_OPT, which leaves xz single-threaded. xz also reads XZ_DEFAULTS, so the deb
|
|
# compresses on every CPU. rpm threads its payload compression on its own.
|
|
XZ_DEFAULTS: -T0
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# `cli` must be the build-cli target that packages/desktop/scripts/utils.ts bundles for `target`.
|
|
settings:
|
|
- host: macos-26
|
|
target: x86_64-apple-darwin
|
|
cli: darwin-x64-baseline
|
|
platform_flag: --mac --x64
|
|
# Both CPUs: arm64 build tools for the host, x64 node-pty for the app.
|
|
bun_install_flags: --os=darwin --cpu=*
|
|
- host: macos-26
|
|
target: aarch64-apple-darwin
|
|
cli: darwin-arm64
|
|
platform_flag: --mac --arm64
|
|
bun_install_flags: --os=darwin --cpu=arm64
|
|
- host: "blacksmith-4vcpu-windows-2025"
|
|
target: aarch64-pc-windows-msvc
|
|
cli: windows-arm64
|
|
platform_flag: --win --arm64
|
|
bun_install_flags: --cpu=*
|
|
- host: "blacksmith-4vcpu-windows-2025"
|
|
target: x86_64-pc-windows-msvc
|
|
cli: windows-x64-baseline
|
|
platform_flag: --win
|
|
- host: "blacksmith-4vcpu-ubuntu-2404"
|
|
target: x86_64-unknown-linux-gnu
|
|
cli: linux-x64-baseline
|
|
platform_flag: --linux
|
|
- host: "blacksmith-4vcpu-ubuntu-2404-arm"
|
|
target: aarch64-unknown-linux-gnu
|
|
cli: linux-arm64
|
|
platform_flag: --linux --arm64
|
|
runs-on: ${{ matrix.settings.host }}
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
|
|
if: runner.os == 'macOS'
|
|
with:
|
|
keychain: build
|
|
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
|
|
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
|
|
|
- name: Setup Apple API Key
|
|
if: runner.os == 'macOS'
|
|
run: echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
|
|
|
|
- uses: ./.github/actions/setup-bun
|
|
with:
|
|
install-flags: ${{ matrix.settings.bun_install_flags }}
|
|
|
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24"
|
|
|
|
- name: Cache apt packages
|
|
if: contains(matrix.settings.host, 'ubuntu')
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: ~/apt-cache
|
|
key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-
|
|
|
|
- name: Install dependencies (ubuntu only)
|
|
if: contains(matrix.settings.host, 'ubuntu')
|
|
run: |
|
|
mkdir -p ~/apt-cache && chmod -R a+rw ~/apt-cache
|
|
sudo apt-get update
|
|
sudo apt-get install -y --no-install-recommends -o dir::cache::archives="$HOME/apt-cache" rpm
|
|
sudo chmod -R a+rw ~/apt-cache
|
|
|
|
- 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 }}
|
|
|
|
# Not `bun run build`: its prebuild hook needs the CLI, so Prepare runs it later.
|
|
- name: Build app
|
|
run: bun run electron-vite build
|
|
working-directory: packages/desktop
|
|
env:
|
|
NODE_OPTIONS: --max-old-space-size=4096
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
|
|
SENTRY_PROJECT: ${{ vars.WEB_SENTRY_PROJECT }}
|
|
SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
|
|
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
|
|
VITE_SENTRY_ENVIRONMENT: ${{ (github.ref_name == 'beta' && 'beta') || 'production' }}
|
|
VITE_SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
|
|
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
|
|
|
# The second argument is GitHub's default name for that build-cli leg. build-app-archive is what build-cli
|
|
# needs, so the wait extends while it runs.
|
|
- name: Wait for the CLI
|
|
run: bun ./script/wait-for-artifact.ts cli-unsigned-${{ matrix.settings.cli }} "build-cli (${{ matrix.settings.cli }})" build-app-archive
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
name: cli-unsigned-${{ matrix.settings.cli }}
|
|
path: packages/cli/dist
|
|
|
|
# The OIDC assertion az refreshes with expires 5 minutes after login, so log in after the wait (AADSTS700024).
|
|
- name: Azure login
|
|
if: runner.os == 'Windows'
|
|
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
|
with:
|
|
client-id: ${{ env.AZURE_CLIENT_ID }}
|
|
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
|
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
- name: Prepare
|
|
run: bun ./scripts/prepare.ts
|
|
working-directory: packages/desktop
|
|
env:
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
|
|
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
|
OPENCODE_CLI_DIST: ${{ github.workspace }}/packages/cli/dist
|
|
|
|
# Any failure retries once below, for transient download, signing or notarization errors. Keep the retry
|
|
# identical.
|
|
- name: Package
|
|
id: package
|
|
if: needs.version.outputs.release
|
|
continue-on-error: true
|
|
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
|
|
working-directory: packages/desktop
|
|
timeout-minutes: 60
|
|
env:
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
|
|
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
|
CSC_KEYCHAIN: build.keychain
|
|
APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
|
|
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
|
|
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
|
|
|
# electron-builder writes only to dist, so the retry reuses out/ and resources/.
|
|
- name: Clean up failed Package
|
|
if: steps.package.outcome == 'failure'
|
|
shell: bash
|
|
run: |
|
|
echo "::warning::Package failed for ${{ matrix.settings.target }}; retrying once in 90 seconds"
|
|
rm -rf packages/desktop/dist
|
|
if [ "$RUNNER_OS" = "macOS" ]; then
|
|
for volume in /Volumes/OpenCode*; do
|
|
[ -d "$volume" ] && hdiutil detach "$volume" -force || true
|
|
done
|
|
fi
|
|
sleep 90
|
|
|
|
# The first login's OIDC assertion has expired by now.
|
|
- name: Azure login (retry)
|
|
if: runner.os == 'Windows' && steps.package.outcome == 'failure'
|
|
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
|
with:
|
|
client-id: ${{ env.AZURE_CLIENT_ID }}
|
|
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
|
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
|
|
|
- name: Package (retry)
|
|
if: steps.package.outcome == 'failure'
|
|
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
|
|
working-directory: packages/desktop
|
|
timeout-minutes: 60
|
|
env:
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
|
|
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
|
CSC_KEYCHAIN: build.keychain
|
|
APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
|
|
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
|
|
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
|
|
|
- name: Package (no publish)
|
|
if: ${{ !needs.version.outputs.release }}
|
|
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
|
|
working-directory: packages/desktop
|
|
timeout-minutes: 60
|
|
env:
|
|
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
|
|
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
|
|
|
- name: Create macOS .app.tar.gz
|
|
if: runner.os == 'macOS' && needs.version.outputs.release
|
|
working-directory: packages/desktop/dist
|
|
run: |
|
|
if [[ "${{ matrix.settings.target }}" == "x86_64-apple-darwin" ]]; then
|
|
APP_DIR="mac"
|
|
OUT_NAME="opencode-desktop-mac-x64.app.tar.gz"
|
|
elif [[ "${{ matrix.settings.target }}" == "aarch64-apple-darwin" ]]; then
|
|
APP_DIR="mac-arm64"
|
|
OUT_NAME="opencode-desktop-mac-arm64.app.tar.gz"
|
|
else
|
|
echo "Unknown macOS target: ${{ matrix.settings.target }}"
|
|
exit 1
|
|
fi
|
|
APP_PATH=$(find "$APP_DIR" -maxdepth 1 -name "*.app" -type d | head -1)
|
|
if [ -z "$APP_PATH" ]; then
|
|
echo "No .app bundle found in $APP_DIR"
|
|
exit 1
|
|
fi
|
|
tar -czf "$OUT_NAME" -C "$(dirname "$APP_PATH")" "$(basename "$APP_PATH")"
|
|
|
|
- name: Verify signed Windows Electron artifacts
|
|
if: runner.os == 'Windows'
|
|
shell: pwsh
|
|
run: |
|
|
$files = @()
|
|
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*.exe" | Select-Object -ExpandProperty FullName
|
|
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*unpacked\*.exe" | Select-Object -ExpandProperty FullName
|
|
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*unpacked\resources\opencode-cli.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
|
|
|
|
foreach ($file in $files | Select-Object -Unique) {
|
|
$sig = Get-AuthenticodeSignature $file
|
|
if ($sig.Status -ne "Valid") {
|
|
throw "Invalid signature for ${file}: $($sig.Status)"
|
|
}
|
|
}
|
|
|
|
# Keep in step with the glob in packages/desktop/scripts/publish.ts (@actions/glob has no brace expansion).
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: opencode-desktop-${{ matrix.settings.target }}
|
|
path: |
|
|
packages/desktop/dist/*.exe
|
|
packages/desktop/dist/*.blockmap
|
|
packages/desktop/dist/*.dmg
|
|
packages/desktop/dist/*.zip
|
|
packages/desktop/dist/*.AppImage
|
|
packages/desktop/dist/*.deb
|
|
packages/desktop/dist/*.rpm
|
|
packages/desktop/dist/*.app.tar.gz
|
|
compression-level: 0
|
|
if-no-files-found: error
|
|
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
if: needs.version.outputs.release
|
|
with:
|
|
name: latest-yml-${{ matrix.settings.target }}
|
|
path: packages/desktop/dist/latest*.yml
|
|
|
|
# No secrets or id-token, so it cannot publish. Beta publishes no npm packages.
|
|
pack-npm:
|
|
needs: version
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 30
|
|
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta'
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
# Same Bun and install as publish, so the tarballs match what publish would build.
|
|
- uses: ./.github/actions/setup-bun
|
|
|
|
- name: Pack npm libraries
|
|
run: ./script/pack-npm.ts
|
|
env:
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_NPM_PACK_DIR: /tmp/npm-libraries
|
|
|
|
# Libraries already on npm at this version are not packed, so a re-dispatched release may have none.
|
|
# NpmLibraries.verify checks the set.
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: npm-libraries
|
|
path: /tmp/npm-libraries/*.tgz
|
|
compression-level: 0
|
|
if-no-files-found: ignore
|
|
|
|
publish:
|
|
needs:
|
|
- version
|
|
- build-cli
|
|
- sign-cli-macos
|
|
- build-app-archive
|
|
- build-node-cli
|
|
- sign-cli-windows
|
|
- build-electron
|
|
- pack-npm
|
|
# When pack-npm fails, a dev preview still publishes the way it did before pack-npm: the libraries build in place
|
|
# in publish order, so one that fails again stops everything after it (the CLI publishes right after client). A
|
|
# release stops.
|
|
if: >-
|
|
always() && !cancelled() && (!failure() || (
|
|
needs.pack-npm.result == 'failure' &&
|
|
!needs.version.outputs.release &&
|
|
needs.build-cli.result != 'failure' &&
|
|
needs.sign-cli-macos.result != 'failure' &&
|
|
needs.sign-cli-windows.result != 'failure' &&
|
|
needs.build-app-archive.result != 'failure' &&
|
|
needs.build-node-cli.result != 'failure' &&
|
|
needs.build-electron.result != 'failure'))
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
steps:
|
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
|
|
|
- uses: ./.github/actions/setup-bun
|
|
|
|
# Only releases push the Docker image.
|
|
- name: Login to GitHub Container Registry
|
|
if: needs.version.outputs.release
|
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up QEMU
|
|
if: needs.version.outputs.release
|
|
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
|
|
|
- name: Set up Docker Buildx
|
|
if: needs.version.outputs.release
|
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
|
|
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
|
with:
|
|
node-version: "24"
|
|
registry-url: "https://registry.npmjs.org"
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: github.ref_name != 'beta'
|
|
with:
|
|
pattern: cli-unsigned-linux-*
|
|
path: packages/cli/dist
|
|
merge-multiple: true
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: github.ref_name != 'beta'
|
|
with:
|
|
pattern: cli-signed-*
|
|
path: packages/cli/dist
|
|
merge-multiple: true
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: needs.build-node-cli.result == 'success'
|
|
with:
|
|
pattern: opencode-node-cli-*
|
|
path: packages/cli/dist/node
|
|
merge-multiple: true
|
|
|
|
# packages/cli/script/publish.ts publishes whatever is in dist, and an unmatched pattern downloads nothing.
|
|
- name: Check CLI packages
|
|
if: github.ref_name != 'beta'
|
|
working-directory: packages/cli/dist
|
|
run: |
|
|
expected="cli-darwin-arm64 cli-darwin-x64 cli-darwin-x64-baseline cli-linux-arm64 cli-linux-arm64-musl cli-linux-x64 cli-linux-x64-baseline cli-linux-x64-baseline-musl cli-linux-x64-musl cli-windows-arm64 cli-windows-x64 cli-windows-x64-baseline"
|
|
actual=$(printf '%s\n' cli-* | LC_ALL=C sort | xargs)
|
|
if [ "$actual" != "$expected" ]; then
|
|
echo "Expected: $expected"
|
|
echo "Found: $actual"
|
|
exit 1
|
|
fi
|
|
|
|
for dir in $expected; do
|
|
binary="$dir/bin/opencode"
|
|
case "$dir" in cli-windows-*) binary="$binary.exe" ;; esac
|
|
if [ ! -f "$dir/package.json" ] || [ ! -s "$binary" ]; then
|
|
echo "$dir needs package.json and a non-empty $binary"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# Unsigned cross-compiled binaries still carry Bun's Developer ID, so match ours by full name.
|
|
for binary in cli-darwin-*/bin/opencode; do
|
|
if ! LC_ALL=C grep -aqF "Developer ID Application: Anomaly Innovations, Inc. (5NZ4Q7NXJ4)" "$binary"; then
|
|
echo "$binary is not signed with the OpenCode Developer ID"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
# Absent when every library was already on npm; script/publish.ts verifies the set either way.
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: needs.pack-npm.result == 'success'
|
|
continue-on-error: true
|
|
with:
|
|
name: npm-libraries
|
|
path: /tmp/npm-libraries
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: needs.version.outputs.release
|
|
with:
|
|
pattern: latest-yml-*
|
|
path: /tmp/latest-yml
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: needs.version.outputs.release
|
|
with:
|
|
pattern: opencode-desktop-*
|
|
path: /tmp/desktop
|
|
merge-multiple: true
|
|
|
|
- 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 }}
|
|
|
|
# Only releases publish to AUR and Homebrew and make release commits with this git identity.
|
|
- name: Cache apt packages (AUR)
|
|
if: needs.version.outputs.release
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: /var/cache/apt/archives
|
|
key: ${{ runner.os }}-apt-aur-${{ hashFiles('.github/workflows/publish.yml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-apt-aur-
|
|
|
|
- name: Setup SSH for AUR
|
|
if: needs.version.outputs.release
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y pacman-package-manager
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
git config --global user.email "opencode@sst.dev"
|
|
git config --global user.name "opencode"
|
|
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
|
|
|
|
- run: ./script/publish.ts
|
|
env:
|
|
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
|
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
|
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'dev' && inputs.release_notes) || '' }}
|
|
AUR_KEY: ${{ secrets.AUR_KEY }}
|
|
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
NPM_CONFIG_PROVENANCE: false
|
|
LATEST_YML_DIR: /tmp/latest-yml
|
|
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
|
|
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
|
|
OPENCODE_DESKTOP_DIST: /tmp/desktop
|
|
OPENCODE_NPM_TARBALLS: ${{ needs.pack-npm.result == 'success' && '/tmp/npm-libraries' || '' }}
|
|
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
|
|
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
|
|
|
notify-discord-v2:
|
|
needs:
|
|
- version
|
|
- publish
|
|
if: ${{ !cancelled() && github.repository == 'anomalyco/opencode' && github.ref_name == 'dev' && needs.version.outputs.release && needs.publish.result == 'success' }}
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
steps:
|
|
# Unlike dev, V2 publishes a tag rather than a GitHub Release event.
|
|
- name: Announce V2 release in Discord
|
|
uses: SethCohen/github-releases-to-discord@24d166886aee4646d448c8a389ff9e1ebcab3682 # v1.20.0
|
|
with:
|
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
|
release_name: OpenCode V2 ${{ needs.version.outputs.tag }}
|
|
release_body: ${{ inputs.release_notes }}
|
|
release_html_url: https://github.com/${{ github.repository }}/tree/${{ needs.version.outputs.tag }}
|