mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
A new pack-npm job applies the release version rewrite and runs the 14 library publish scripts in a pack-only mode (OPENCODE_NPM_PACK_DIR), with their typecheck, ui tests and codemode smoke install, and uploads the tarballs. It has only contents: read and no secrets. publish downloads them and sets OPENCODE_NPM_TARBALLS. script/publish.ts checks that every tarball exists and holds the expected name and version before it publishes anything, and each library script keeps its npm view check and then publishes its carried tarball instead of building again. Without either variable the scripts behave as before. The version rewrite moves to script/release-files.ts so publish and pack-npm share it.
793 lines
32 KiB
YAML
793 lines
32 KiB
YAML
name: publish
|
|
run-name: "${{ format('release {0}', inputs.bump) }}"
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- ci
|
|
- dev
|
|
- beta
|
|
- fix/npm-native-binary-install
|
|
- snapshot-*
|
|
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
|
|
# Desktop jobs poll this run's artifacts and jobs while the CLI builds.
|
|
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 }}
|
|
|
|
# Each target builds in its own job and artifact, so signers and desktop jobs download only the CLIs they use.
|
|
build-cli:
|
|
needs: version
|
|
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
|
|
|
|
- name: Build CLI
|
|
run: ./packages/cli/script/build.ts --target=opencode-${{ matrix.target }}
|
|
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: ${{ github.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-app-archive:
|
|
needs: version
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
timeout-minutes: 30
|
|
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta' && !(github.ref_name == 'dev' && (inputs.bump || inputs.version))
|
|
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-node-app-archive
|
|
path: packages/cli/.cache/app-archive.bin
|
|
if-no-files-found: error
|
|
|
|
build-node-cli:
|
|
needs:
|
|
- version
|
|
- build-node-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-node-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.
|
|
# It builds the app while build-cli runs and waits for its own CLI just 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 }}
|
|
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
|
|
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 }}
|
|
|
|
# The app builds before its CLI exists. `bun run build` would run the prebuild hook, which copies the CLI;
|
|
# Prepare runs it once the CLI is here.
|
|
- 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 job name is the one GitHub gives the build-cli leg for this target.
|
|
- name: Wait for the CLI
|
|
run: bun ./script/wait-for-artifact.ts cli-unsigned-${{ matrix.settings.cli }} "build-cli (${{ matrix.settings.cli }})"
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
with:
|
|
name: cli-unsigned-${{ matrix.settings.cli }}
|
|
path: packages/cli/dist
|
|
|
|
# az requests new Azure tokens with the GitHub OIDC token, which expires 5 minutes after login. Prepare requests
|
|
# the first signing token, so a login before a long wait would fail it with 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
|
|
|
|
# A transient download, signing timestamp or notarization error in one leg fails the whole release, so a failed
|
|
# Package retries once below. Keep the retry identical to this step.
|
|
- 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 }}
|
|
|
|
# Only dist holds electron-builder output. It copies out/ (the app build) and resources/ (the CLI from Prepare)
|
|
# into dist rather than changing them, so the retry reuses both.
|
|
- 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
|
|
|
|
- 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)"
|
|
}
|
|
}
|
|
|
|
# publish merges these artifacts into OPENCODE_DESKTOP_DIST, and packages/desktop/scripts/publish.ts ships only
|
|
# its top-level *.{exe,blockmap,dmg,zip,AppImage,deb,rpm,app.tar.gz} files. @actions/glob has no brace expansion,
|
|
# so keep one line per extension in step with that glob. The installers are already compressed.
|
|
- 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
|
|
|
|
# Builds and packs the npm libraries while the CLI builds, so publish only publishes them. It gets no secrets or
|
|
# id-token, so it cannot publish anything. 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
|
|
|
|
# The same Bun and install as publish, so the tarballs match the ones 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
|
|
|
|
# The tarballs are already gzipped.
|
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: npm-libraries
|
|
path: /tmp/npm-libraries/*.tgz
|
|
compression-level: 0
|
|
if-no-files-found: error
|
|
|
|
publish:
|
|
needs:
|
|
- version
|
|
- build-cli
|
|
- sign-cli-macos
|
|
- build-node-app-archive
|
|
- build-node-cli
|
|
- sign-cli-windows
|
|
- build-electron
|
|
- pack-npm
|
|
if: always() && !failure() && !cancelled()
|
|
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 (packages/cli/script/publish.ts).
|
|
- 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 every package in dist, and a pattern that matches nothing downloads
|
|
# nothing, so check that dist holds each target once and that no macOS binary is unsigned.
|
|
- 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
|
|
|
|
# Cross-compiled macOS binaries keep Bun's own, now invalid, Developer ID signature, so match the full name of
|
|
# the certificate sign-cli-macos signs with.
|
|
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
|
|
|
|
# script/publish.ts checks these tarballs before it publishes anything, and the library scripts publish them
|
|
# instead of building again.
|
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
|
if: github.ref_name != 'beta'
|
|
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, which use the git identity set below.
|
|
- 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: /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 }}
|