mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-21 04:12:08 +03:00
ci: separate release builds from signing and publishing (#59046)
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# web + desktop packages
|
||||
packages/app/ @Hona @Brendonovich
|
||||
packages/desktop/ @Hona @Brendonovich
|
||||
|
||||
# CI and releases. Release jobs that hold secrets run only .github/workflows/release.yml and .github/release/,
|
||||
# which makes this path the release security boundary.
|
||||
/.github/ @anomalyco/ci-owners
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
#
|
||||
# This file is intentionally in the wrong dir, will move and add later....
|
||||
#
|
||||
|
||||
# name: publish-python-sdk
|
||||
|
||||
# on:
|
||||
# release:
|
||||
# types: [published]
|
||||
# workflow_dispatch:
|
||||
|
||||
# jobs:
|
||||
# publish:
|
||||
# runs-on: ubuntu-latest
|
||||
# permissions:
|
||||
# contents: read
|
||||
# steps:
|
||||
# - name: Checkout repository
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: Setup Bun
|
||||
# uses: oven-sh/setup-bun@v1
|
||||
# with:
|
||||
# bun-version: 1.2.21
|
||||
|
||||
# - name: Install dependencies (JS/Bun)
|
||||
# run: bun install
|
||||
|
||||
# - name: Install uv
|
||||
# shell: bash
|
||||
# run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
# - name: Generate Python SDK from OpenAPI (CLI)
|
||||
# shell: bash
|
||||
# run: |
|
||||
# ~/.local/bin/uv run --project packages/sdk/python python packages/sdk/python/scripts/generate.py --source cli
|
||||
|
||||
# - name: Sync Python dependencies
|
||||
# shell: bash
|
||||
# run: |
|
||||
# ~/.local/bin/uv sync --dev --project packages/sdk/python
|
||||
|
||||
# - name: Set version from release tag
|
||||
# shell: bash
|
||||
# run: |
|
||||
# TAG="${GITHUB_REF_NAME:-}"
|
||||
# if [ -z "$TAG" ]; then
|
||||
# TAG="$(git describe --tags --abbrev=0 || echo 0.0.0)"
|
||||
# fi
|
||||
# echo "Using version: $TAG"
|
||||
# VERSION="$TAG" ~/.local/bin/uv run --project packages/sdk/python python - <<'PY'
|
||||
# import os, re, pathlib
|
||||
# root = pathlib.Path('packages/sdk/python')
|
||||
# pt = (root / 'pyproject.toml').read_text()
|
||||
# version = os.environ.get('VERSION','0.0.0').lstrip('v')
|
||||
# pt = re.sub(r'(?m)^(version\s*=\s*")[^"]+("\s*)$', f"\\1{version}\\2", pt)
|
||||
# (root / 'pyproject.toml').write_text(pt)
|
||||
# # Also update generator config override for consistency
|
||||
# cfgp = root / 'openapi-python-client.yaml'
|
||||
# if cfgp.exists():
|
||||
# cfg = cfgp.read_text()
|
||||
# cfg = re.sub(r'(?m)^(package_version_override:\s*)\S+$', f"\\1{version}", cfg)
|
||||
# cfgp.write_text(cfg)
|
||||
# PY
|
||||
|
||||
# - name: Build and publish to PyPI
|
||||
# env:
|
||||
# PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
||||
# shell: bash
|
||||
# run: |
|
||||
# ~/.local/bin/uv run --project packages/sdk/python python packages/sdk/python/scripts/publish.py
|
||||
@@ -0,0 +1,21 @@
|
||||
name: Download release artifacts
|
||||
description: Downloads artifacts into $RUNNER_TEMP/in/<name> and verifies each against its SHA256SUMS.
|
||||
inputs:
|
||||
pattern:
|
||||
description: Artifact name pattern
|
||||
required: true
|
||||
digests:
|
||||
description: Space-separated name=digest pairs for artifacts made by sign jobs, from their job outputs
|
||||
required: false
|
||||
default: ""
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: ${{ inputs.pattern }}
|
||||
path: ${{ runner.temp }}/in
|
||||
- shell: bash
|
||||
run: bash "${GITHUB_ACTION_PATH//\\//}/../verify-artifacts.sh" "$RUNNER_TEMP/in"
|
||||
env:
|
||||
OPENCODE_DIGESTS: ${{ inputs.digests }}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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.disable-library-validation</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?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.device.audio-input</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,109 @@
|
||||
# Shared helpers for the release scripts. Sourced, never executed.
|
||||
#
|
||||
# These scripts run in sign and publish jobs that hold secrets. They must never execute repository code
|
||||
# or artifact contents: artifacts are data, and every value that names a destination comes from the
|
||||
# environment the workflow sets (OPENCODE_VERSION, OPENCODE_CHANNEL, OPENCODE_DRY_RUN, ...).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck disable=SC2034 # used by the scripts that source this file
|
||||
release_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
die() {
|
||||
echo "::error::$*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
dry_run() {
|
||||
[ "${OPENCODE_DRY_RUN:-false}" = true ]
|
||||
}
|
||||
|
||||
sha256() {
|
||||
if command -v sha256sum > /dev/null; then sha256sum "$@"; else shasum -a 256 "$@"; fi
|
||||
}
|
||||
|
||||
# Windows runners pass D:\a\_temp style paths; Git Bash tools want /d/a/_temp.
|
||||
posix() {
|
||||
if command -v cygpath > /dev/null; then cygpath -u "$1"; else printf '%s' "$1"; fi
|
||||
}
|
||||
|
||||
size() {
|
||||
wc -c < "$1" | tr -d ' '
|
||||
}
|
||||
|
||||
# Uploads files to opencode.ai/files/bin/<version>/ and prints the update-server file map.
|
||||
upload_files() {
|
||||
local credentials=false
|
||||
for file in "$@"; do
|
||||
test -s "$file" || die "Missing release file: $file"
|
||||
local name type
|
||||
name=$(basename "$file")
|
||||
case "$name" in
|
||||
*.tar.gz) type=application/gzip ;;
|
||||
*.zip) type=application/zip ;;
|
||||
*) type=application/octet-stream ;;
|
||||
esac
|
||||
if dry_run; then
|
||||
echo "dry-run upload: bin/$OPENCODE_VERSION/$name" >&2
|
||||
else
|
||||
if [ "$credentials" = false ]; then
|
||||
r2_credentials
|
||||
credentials=true
|
||||
fi
|
||||
aws s3 cp "$file" "s3://opencode-production-files/bin/$OPENCODE_VERSION/$name" --only-show-errors \
|
||||
--endpoint-url "https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com" \
|
||||
--content-type "$type" --content-disposition "attachment; filename=\"$name\"" \
|
||||
--cache-control "public, max-age=31536000, immutable" >&2
|
||||
fi
|
||||
jq -n --arg name "$name" --arg url "https://opencode.ai/files/bin/$OPENCODE_VERSION/$name" \
|
||||
--arg sha256 "$(sha256 "$file" | cut -c1-64)" --argjson size "$(size "$file")" \
|
||||
'{($name): {url: $url, sha256: $sha256, size: $size}}'
|
||||
done | jq -s 'add'
|
||||
}
|
||||
|
||||
# R2 accepts the API token ID as the access key and SHA-256(token) as the secret.
|
||||
r2_credentials() {
|
||||
local id
|
||||
id=$(curl -fsS -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
|
||||
"https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/tokens/verify" | jq -er .result.id)
|
||||
export AWS_ACCESS_KEY_ID="$id"
|
||||
AWS_SECRET_ACCESS_KEY=$(printf '%s' "$CLOUDFLARE_API_TOKEN" | sha256 | cut -c1-64)
|
||||
export AWS_SECRET_ACCESS_KEY
|
||||
export AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required AWS_RESPONSE_CHECKSUM_VALIDATION=when_required
|
||||
}
|
||||
|
||||
# Registers one artifact with the update server: publish_update <name> <distribution> <metadata json>.
|
||||
publish_update() {
|
||||
local body status token attempt
|
||||
body=$(jq -n --arg channel "$OPENCODE_CHANNEL" --arg version "$OPENCODE_VERSION" --arg name "$1" --arg distribution "$2" \
|
||||
--argjson metadata "$3" '{channel: $channel, name: $name, distribution: $distribution, version: $version, metadata: $metadata}')
|
||||
echo "$body" | jq .
|
||||
if dry_run; then return; fi
|
||||
token=$(curl -fsS -H "Authorization: Bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
|
||||
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://update.opencode.ai" | jq -er .value)
|
||||
for attempt in 1 2 3; do
|
||||
status=$(curl -sS -o "$RUNNER_TEMP/update-response" -w '%{http_code}' -X POST https://opencode.ai/update/api/publish \
|
||||
-H "Authorization: Bearer $token" -H "Content-Type: application/json" --data "$body")
|
||||
if [ "$status" -lt 300 ]; then return; fi
|
||||
cat "$RUNNER_TEMP/update-response"
|
||||
# D1 can commit the upsert and still time out. Replaying the same artifact is safe.
|
||||
if [ "$status" -lt 500 ] || [ "$attempt" = 3 ]; then die "Update server returned $status"; fi
|
||||
sleep "$attempt"
|
||||
done
|
||||
}
|
||||
|
||||
# Clones a repository, lets a render script fill it, then commits and pushes any change:
|
||||
# push_git <clone url> <commit message> <render script> [args...]. Dry runs render into an empty directory.
|
||||
push_git() {
|
||||
local url=$1 message=$2 dir
|
||||
shift 2
|
||||
dir=$(mktemp -d)
|
||||
if ! dry_run; then git clone -q "$url" "$dir"; fi
|
||||
"$@" "$dir"
|
||||
if dry_run; then return; fi
|
||||
git -C "$dir" add -A
|
||||
if git -C "$dir" diff --cached --quiet; then return; fi
|
||||
git -C "$dir" -c user.name="opencode-agent[bot]" -c user.email="opencode-agent[bot]@users.noreply.github.com" \
|
||||
commit -q -m "$message"
|
||||
git -C "$dir" push -q origin HEAD:master
|
||||
}
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
# plan-release.sh: decides version, channel and npm dist-tag from the event, ref and dispatch inputs
|
||||
# (INPUT_BUMP, INPUT_VERSION) only, and writes them to $GITHUB_OUTPUT. Nothing here reads repository files.
|
||||
#
|
||||
# push or dispatch on dev -> dev 0.0.0-dev-<run> npm tag dev
|
||||
# dispatch on dev with bump/version -> latest x.y.z npm tag latest
|
||||
# push or dispatch on beta -> beta 0.0.0-beta-<run> desktop only
|
||||
# pull_request -> pr 0.0.0-pr-<run> everything, dry run
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
versioned=false
|
||||
if [ -n "${INPUT_BUMP:-}" ] || [ -n "${INPUT_VERSION:-}" ]; then versioned=true; fi
|
||||
case "$GITHUB_EVENT_NAME:$GITHUB_REF:$versioned" in
|
||||
push:refs/heads/dev:false | workflow_dispatch:refs/heads/dev:false) channel="dev" ;;
|
||||
workflow_dispatch:refs/heads/dev:true) channel="latest" ;;
|
||||
push:refs/heads/beta:false | workflow_dispatch:refs/heads/beta:false) channel="beta" ;;
|
||||
pull_request:*:false) channel="pr" ;;
|
||||
*) die "$GITHUB_EVENT_NAME on $GITHUB_REF cannot publish (versioned: $versioned)" ;;
|
||||
esac
|
||||
|
||||
if [ "$channel" = latest ] && [ -n "${INPUT_VERSION:-}" ]; then
|
||||
version=$INPUT_VERSION
|
||||
elif [ "$channel" = latest ]; then
|
||||
current=$(curl -fsS https://registry.npmjs.org/-/package/@opencode%2fcli/dist-tags | jq -r .latest)
|
||||
[[ "$current" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]] || die "Unexpected latest version: $current"
|
||||
major=${BASH_REMATCH[1]} minor=${BASH_REMATCH[2]} patch=${BASH_REMATCH[3]}
|
||||
case "$INPUT_BUMP" in
|
||||
major) version="$((major + 1)).0.0" ;;
|
||||
minor) version="$major.$((minor + 1)).0" ;;
|
||||
*) version="$major.$minor.$((patch + 1))" ;;
|
||||
esac
|
||||
if [ "$major" -lt 2 ]; then version=2.0.0; fi
|
||||
else
|
||||
version="0.0.0-$channel-$GITHUB_RUN_NUMBER"
|
||||
if [ "$GITHUB_RUN_ATTEMPT" != 1 ]; then version="$version.$GITHUB_RUN_ATTEMPT"; fi
|
||||
fi
|
||||
|
||||
if [ "$channel" = latest ]; then
|
||||
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || [[ "$version" == 0.0.0-* ]]; then
|
||||
die "Invalid release version: $version"
|
||||
fi
|
||||
status=$(curl -sS -o /dev/null -w '%{http_code}' "https://registry.npmjs.org/@opencode%2fcli/$version")
|
||||
[ "$status" != 200 ] || die "@opencode/cli@$version is already published"
|
||||
fi
|
||||
|
||||
# What each channel builds and publishes.
|
||||
case "$channel" in
|
||||
latest) npm_tag=latest cli=true desktop=true node=false release=true ;;
|
||||
dev) npm_tag=dev cli=true desktop=false node=true release=false ;;
|
||||
beta) npm_tag="" cli=false desktop=true node=false release=false ;;
|
||||
pr) npm_tag=pr cli=true desktop=true node=true release=true ;;
|
||||
esac
|
||||
dry_run=false
|
||||
if [ "$channel" = pr ]; then dry_run=true; fi
|
||||
|
||||
{
|
||||
echo "version=$version"
|
||||
echo "channel=$channel"
|
||||
echo "npm_tag=$npm_tag"
|
||||
echo "dry_run=$dry_run"
|
||||
echo "cli=$cli"
|
||||
echo "desktop=$desktop"
|
||||
echo "node=$node"
|
||||
echo "release=$release"
|
||||
} | tee -a "$GITHUB_OUTPUT"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-aur.sh <build-npm dir>: updates opencode-beta on the AUR over SSH (AUR_KEY, pinned host key) and
|
||||
# registers the aur update artifact.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
if ! dry_run; then
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s\n' "$AUR_KEY" > ~/.ssh/aur
|
||||
chmod 600 ~/.ssh/aur
|
||||
echo "aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN" > ~/.ssh/known_hosts
|
||||
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/aur -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes"
|
||||
fi
|
||||
push_git ssh://aur@aur.archlinux.org/opencode-beta.git "chore: update opencode-beta to ${OPENCODE_VERSION//-/.}" \
|
||||
bash "$release_dir/render-aur.sh" "$1"
|
||||
publish_update cli aur '{"package": "opencode-beta"}'
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-cli.sh <build-archives dir> <sign-macos dir> <sign-windows dir>: uploads the standalone CLI
|
||||
# archives to opencode.ai/files and registers the cli (and, off latest, cli-node) update artifacts.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
archives=$1 macos=$2 windows=$3
|
||||
cli=()
|
||||
for target in linux-arm64 linux-x64 linux-x64-baseline linux-arm64-musl linux-x64-musl linux-x64-baseline-musl; do cli+=("$archives/opencode-$target.tar.gz"); done
|
||||
for target in darwin-arm64 darwin-x64 darwin-x64-baseline; do cli+=("$macos/opencode-$target.zip"); done
|
||||
for target in windows-arm64 windows-x64 windows-x64-baseline; do cli+=("$windows/opencode-$target.zip"); done
|
||||
|
||||
files=$(upload_files "${cli[@]}")
|
||||
publish_update cli npm '{"package": "@opencode/cli"}'
|
||||
publish_update cli opencode "$(jq -n --argjson files "$files" '{files: $files}')"
|
||||
|
||||
if [ "$OPENCODE_CHANNEL" != latest ]; then
|
||||
node=()
|
||||
for target in linux-arm64 linux-x64; do node+=("$archives/opencode2-node-$target.tar.gz"); done
|
||||
for target in darwin-arm64 windows-arm64 windows-x64; do node+=("$archives/opencode2-node-$target.zip"); done
|
||||
files=$(upload_files "${node[@]}")
|
||||
publish_update cli-node npm '{"package": "@opencode/cli-node"}'
|
||||
publish_update cli-node opencode "$(jq -n --argjson files "$files" '{files: $files}')"
|
||||
fi
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-desktop.sh <sign-macos dir> <sign-desktop-windows-installer dir> <build-desktop-linux-x64 dir>
|
||||
# <build-desktop-linux-arm64 dir>: uploads the desktop builds to opencode.ai/files and registers the desktop update
|
||||
# artifact. The electron-updater feeds (latest*.yml) are computed here from the final signed files.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
macos=$1 windows=$2 linux_x64=$3 linux_arm64=$4
|
||||
win=("$windows/opencode-desktop-win-arm64.exe" "$windows/opencode-desktop-win-x64.exe")
|
||||
mac=("$macos/opencode-desktop-mac-arm64.zip" "$macos/opencode-desktop-mac-arm64.dmg" "$macos/opencode-desktop-mac-x64.zip" "$macos/opencode-desktop-mac-x64.dmg")
|
||||
linux=("$linux_x64/opencode-desktop-linux-x86_64.AppImage" "$linux_x64/opencode-desktop-linux-amd64.deb" "$linux_x64/opencode-desktop-linux-x86_64.rpm")
|
||||
linux_arm=("$linux_arm64/opencode-desktop-linux-arm64.AppImage" "$linux_arm64/opencode-desktop-linux-arm64.deb" "$linux_arm64/opencode-desktop-linux-aarch64.rpm")
|
||||
# Beta skips the .app.tar.gz, which only the retired Tauri updater feed read.
|
||||
bundles=()
|
||||
if [ "$OPENCODE_CHANNEL" != beta ]; then
|
||||
bundles=("$macos/opencode-desktop-mac-arm64.app.tar.gz" "$macos/opencode-desktop-mac-x64.app.tar.gz")
|
||||
fi
|
||||
|
||||
feed() {
|
||||
for file in "$@"; do
|
||||
jq -n --arg url "https://opencode.ai/files/bin/$OPENCODE_VERSION/$(basename "$file")" \
|
||||
--arg sha512 "$(openssl dgst -sha512 -binary "$file" | base64 | tr -d '\n')" --argjson size "$(size "$file")" \
|
||||
'{url: $url, sha512: $sha512, size: $size}'
|
||||
done | jq -s --arg date "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" '{files: ., releaseDate: $date}'
|
||||
}
|
||||
|
||||
files=$(upload_files "${win[@]}" "${mac[@]}" "${linux[@]}" "${linux_arm[@]}" "${bundles[@]}")
|
||||
manifests=$(jq -n --argjson win "$(feed "${win[@]}")" --argjson mac "$(feed "${mac[@]}")" \
|
||||
--argjson linux "$(feed "${linux[@]}")" --argjson linux_arm64 "$(feed "${linux_arm[@]}")" \
|
||||
'{"desktop.yml": $win, "desktop-mac.yml": $mac, "desktop-linux.yml": $linux, "desktop-linux-arm64.yml": $linux_arm64}')
|
||||
publish_update desktop opencode "$(jq -n --argjson files "$files" --argjson manifests "$manifests" '{files: $files, manifests: $manifests}')"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-docker.sh <build-docker dir>: pushes the multi-arch OCI image to ghcr.io/anomalyco/opencode:<version>
|
||||
# without building anything (GH_TOKEN with packages: write).
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
image="$1/opencode-image.tar"
|
||||
skopeo inspect --raw "oci-archive:$image" | jq .
|
||||
if dry_run; then exit 0; fi
|
||||
printf '%s' "$GH_TOKEN" | skopeo login ghcr.io --username "$GITHUB_ACTOR" --password-stdin
|
||||
skopeo copy --all "oci-archive:$image" "docker://ghcr.io/anomalyco/opencode:$OPENCODE_VERSION"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-github-release.sh <dir>...: attaches the CLI archives and desktop builds in the given artifact dirs, plus
|
||||
# a SHA256SUMS, to the v<version> GitHub release with OPENCODE_RELEASE_NOTES. Immutable releases lock assets once
|
||||
# published, so they go to a draft first.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
assets=$(mktemp -d)
|
||||
for dir in "$@"; do
|
||||
find "$dir" -maxdepth 1 -type f \( -name 'opencode-*.zip' -o -name 'opencode-*.tar.gz' -o -name 'opencode-desktop-*' \) \
|
||||
! -name '*.tgz' ! -name '*.app.tar' -exec cp {} "$assets/" \;
|
||||
done
|
||||
(cd "$assets" && sha256 -- * > SHA256SUMS && cat SHA256SUMS)
|
||||
printf '%s\n' "${OPENCODE_RELEASE_NOTES:-}" > "$assets.md"
|
||||
if dry_run; then exit 0; fi
|
||||
|
||||
tag="v$OPENCODE_VERSION"
|
||||
gh release view "$tag" > /dev/null 2>&1 || gh release create "$tag" --draft --verify-tag --title "$tag" --notes-file "$assets.md"
|
||||
gh release upload "$tag" "$assets"/* --clobber
|
||||
gh release edit "$tag" --draft=false
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-homebrew.sh <sign-macos dir> <build-archives dir>: updates opencode-v2 in anomalyco/homebrew-tap
|
||||
# (HOMEBREW_TOKEN) and registers the homebrew update artifact.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
push_git "https://x-access-token:${HOMEBREW_TOKEN:-}@github.com/anomalyco/homebrew-tap.git" \
|
||||
"chore: update opencode-v2 to $OPENCODE_VERSION" bash "$release_dir/render-homebrew.sh" "$1" "$2"
|
||||
publish_update cli homebrew '{"package": "anomalyco/tap/opencode-v2"}'
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-npm.sh <build-npm dir> <signed dir>...: publishes every release tarball to npm with OPENCODE_NPM_TAG.
|
||||
# Names, the version and the package set come from this script, never from the tarballs: each tarball's
|
||||
# package.json is read as data and must match. macOS and Windows CLI packages must come from a signed dir.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
npm_dir=$1
|
||||
shift
|
||||
targets="linux-arm64 linux-x64 linux-x64-baseline linux-arm64-musl linux-x64-musl linux-x64-baseline-musl darwin-arm64 darwin-x64 darwin-x64-baseline windows-arm64 windows-x64 windows-x64-baseline"
|
||||
expected="@opencode/cli"
|
||||
for target in $targets; do expected="$expected @opencode/cli-$target"; done
|
||||
for lib in schema codemode theme ai util protocol client plugin plugin-browser core simulation server sdk ui; do expected="$expected @opencode/$lib"; done
|
||||
if [ "$OPENCODE_CHANNEL" != latest ]; then
|
||||
expected="$expected @opencode/cli-node"
|
||||
for target in linux-arm64 linux-x64 darwin-arm64 windows-arm64 windows-x64; do expected="$expected @opencode/cli-node-$target"; done
|
||||
fi
|
||||
|
||||
if ! dry_run; then
|
||||
for file in "$npm_dir"/*.tgz; do
|
||||
gh attestation verify "$file" --repo anomalyco/opencode --signer-workflow anomalyco/opencode/.github/workflows/release.yml > /dev/null
|
||||
done
|
||||
fi
|
||||
|
||||
shopt -s nullglob
|
||||
files=()
|
||||
for dir in "$@"; do files+=("$dir"/*.tgz); done
|
||||
files+=("$npm_dir"/*.tgz)
|
||||
list=$(mktemp)
|
||||
for file in "${files[@]}"; do
|
||||
IFS=$'\t' read -r name version config install < <(tar -xzOf "$file" package/package.json |
|
||||
jq -r '[.name, .version, ((.publishConfig // {}) | keys - ["access"] | length > 0),
|
||||
((.scripts // {}) | (has("preinstall") or has("install") or has("postinstall")))] | @tsv')
|
||||
# shellcheck disable=SC2086 # $expected is a word list
|
||||
printf '%s\n' $expected | grep -qxF -- "$name" || die "Unexpected package $name in $file"
|
||||
# The signed copy of a macOS or Windows CLI package replaces the unsigned one from the build.
|
||||
if cut -f1 "$list" | grep -qxF -- "$name"; then continue; fi
|
||||
case "$name:$file" in
|
||||
@opencode/cli-darwin-*:"$npm_dir"/* | @opencode/cli-windows-*:"$npm_dir"/*) die "$name is not signed" ;;
|
||||
esac
|
||||
[ "$version" = "$OPENCODE_VERSION" ] || die "$name has version $version, expected $OPENCODE_VERSION"
|
||||
[ "$config" = false ] || die "$name sets publishConfig beyond access"
|
||||
[ "$install" = false ] || [ "$name" = @opencode/cli ] || [ "$name" = @opencode/cli-node ] || die "$name has an install script"
|
||||
printf '%s\t%s\n' "$name" "$file" >> "$list"
|
||||
done
|
||||
for name in $expected; do cut -f1 "$list" | grep -qxF -- "$name" || die "Missing package $name"; done
|
||||
|
||||
# The CLI wrappers resolve their platform packages, so they publish last.
|
||||
order=$(mktemp)
|
||||
{ grep -vP '^@opencode/cli(-node)?\t' "$list" || true; grep -P '^@opencode/cli(-node)?\t' "$list"; } > "$order"
|
||||
cat "$order"
|
||||
|
||||
# A clean directory and config, so nothing from an artifact can redirect the registry.
|
||||
printf 'registry=https://registry.npmjs.org/\n' > "$RUNNER_TEMP/npmrc"
|
||||
export NPM_CONFIG_USERCONFIG="$RUNNER_TEMP/npmrc"
|
||||
cd "$(mktemp -d)"
|
||||
flags=(--tag "$OPENCODE_NPM_TAG" --access public --ignore-scripts)
|
||||
if dry_run; then flags+=(--dry-run); else flags+=(--provenance); fi
|
||||
while IFS=$'\t' read -r name file; do
|
||||
if ! dry_run && npm view "$name@$OPENCODE_VERSION" version > /dev/null 2>&1; then
|
||||
echo "already published $name@$OPENCODE_VERSION"
|
||||
continue
|
||||
fi
|
||||
npm publish "$file" "${flags[@]}"
|
||||
done < "$order"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# publish-version-pr.sh <sha>: opens the pull request that brings the release commit (versions and changelog) back to dev.
|
||||
# Pushing to dev is blocked by rulesets, so this never merges.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
branch="release-v$OPENCODE_VERSION"
|
||||
gh api "repos/$GH_REPO/git/refs" -f "ref=refs/heads/$branch" -f "sha=$1" > /dev/null ||
|
||||
gh api "repos/$GH_REPO/git/refs/heads/$branch" > /dev/null
|
||||
body="Brings the versions and changelog of the published \`v$OPENCODE_VERSION\` release back to \`dev\`. The \`v$OPENCODE_VERSION\` tag points at this commit."
|
||||
gh pr create --base dev --head "$branch" --title "release: v$OPENCODE_VERSION" --body "$body" ||
|
||||
echo "::warning::Could not open the release PR. Open it by hand: gh pr create --base dev --head $branch"
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
# render-aur.sh <build-npm dir> <aur dir>: writes PKGBUILD, .SRCINFO and the opencode2 shim for opencode-beta.
|
||||
# The package installs the published npm tarballs, so their hashes come from the build-npm artifact.
|
||||
# LICENSE comes from the AUR repository itself.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
npm=$1 aur=$2
|
||||
name=opencode-beta
|
||||
pkgver="${OPENCODE_VERSION//-/.}"
|
||||
if dry_run && [ ! -f "$aur/LICENSE" ]; then printf 'MIT License\n' > "$aur/LICENSE"; fi
|
||||
test -s "$aur/LICENSE" || die "The AUR repository has no LICENSE"
|
||||
printf '#!/bin/sh\nexec "$(dirname "$0")/opencode" "$@"\n' > "$aur/opencode2"
|
||||
sum() { sha256 "$1" | cut -c1-64; }
|
||||
x64=$(sum "$npm/opencode-cli-linux-x64-baseline-$OPENCODE_VERSION.tgz")
|
||||
arm64=$(sum "$npm/opencode-cli-linux-arm64-$OPENCODE_VERSION.tgz")
|
||||
x64_url="https://registry.npmjs.org/@opencode/cli-linux-x64-baseline/-/cli-linux-x64-baseline-$OPENCODE_VERSION.tgz"
|
||||
arm64_url="https://registry.npmjs.org/@opencode/cli-linux-arm64/-/cli-linux-arm64-$OPENCODE_VERSION.tgz"
|
||||
license=$(sum "$aur/LICENSE")
|
||||
shim=$(sum "$aur/opencode2")
|
||||
|
||||
# Stripping a compiled Bun executable can damage its embedded application.
|
||||
cat > "$aur/PKGBUILD" <<PKGBUILD
|
||||
# Maintainer: Dax <mail@thdxr.com>
|
||||
pkgname=$name
|
||||
pkgver=$pkgver
|
||||
pkgrel=1
|
||||
pkgdesc='OpenCode beta - the AI coding agent for the terminal'
|
||||
url='https://github.com/anomalyco/opencode'
|
||||
arch=('x86_64' 'aarch64')
|
||||
license=('MIT')
|
||||
depends=('glibc' 'gcc-libs' 'ripgrep')
|
||||
provides=('opencode' 'opencode2')
|
||||
conflicts=('opencode' 'opencode2')
|
||||
options=('!strip' '!debug')
|
||||
source=('LICENSE' 'opencode2')
|
||||
sha256sums=('$license' '$shim')
|
||||
source_x86_64=('$name-$pkgver-x86_64.tgz::$x64_url')
|
||||
sha256sums_x86_64=('$x64')
|
||||
source_aarch64=('$name-$pkgver-aarch64.tgz::$arm64_url')
|
||||
sha256sums_aarch64=('$arm64')
|
||||
|
||||
package() {
|
||||
install -Dm755 "\$srcdir/package/bin/opencode" "\$pkgdir/usr/bin/opencode"
|
||||
install -Dm755 "\$srcdir/opencode2" "\$pkgdir/usr/bin/opencode2"
|
||||
install -Dm644 "\$srcdir/LICENSE" "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
|
||||
}
|
||||
PKGBUILD
|
||||
|
||||
# What makepkg --printsrcinfo prints for the PKGBUILD above.
|
||||
t=$'\t'
|
||||
cat > "$aur/.SRCINFO" <<SRCINFO
|
||||
pkgbase = $name
|
||||
${t}pkgdesc = OpenCode beta - the AI coding agent for the terminal
|
||||
${t}pkgver = $pkgver
|
||||
${t}pkgrel = 1
|
||||
${t}url = https://github.com/anomalyco/opencode
|
||||
${t}arch = x86_64
|
||||
${t}arch = aarch64
|
||||
${t}license = MIT
|
||||
${t}depends = glibc
|
||||
${t}depends = gcc-libs
|
||||
${t}depends = ripgrep
|
||||
${t}provides = opencode
|
||||
${t}provides = opencode2
|
||||
${t}conflicts = opencode
|
||||
${t}conflicts = opencode2
|
||||
${t}options = !strip
|
||||
${t}options = !debug
|
||||
${t}source = LICENSE
|
||||
${t}source = opencode2
|
||||
${t}sha256sums = $license
|
||||
${t}sha256sums = $shim
|
||||
${t}source_x86_64 = $name-$pkgver-x86_64.tgz::$x64_url
|
||||
${t}sha256sums_x86_64 = $x64
|
||||
${t}source_aarch64 = $name-$pkgver-aarch64.tgz::$arm64_url
|
||||
${t}sha256sums_aarch64 = $arm64
|
||||
|
||||
pkgname = $name
|
||||
SRCINFO
|
||||
cat "$aur/PKGBUILD" "$aur/.SRCINFO"
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# render-homebrew.sh <sign-macos dir> <build-archives dir> <tap dir>: writes Formula opencode-v2.rb with the
|
||||
# hashes of the signed macOS and the Linux archives.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
macos=$1 archives=$2 tap=$3
|
||||
sum() { sha256 "$1" | cut -c1-64; }
|
||||
base="https://opencode.ai/files/bin/$OPENCODE_VERSION"
|
||||
cat > "$tap/opencode-v2.rb" <<FORMULA
|
||||
# typed: false
|
||||
# frozen_string_literal: true
|
||||
|
||||
class OpencodeV2 < Formula
|
||||
desc "OpenCode V2 - the AI coding agent for the terminal"
|
||||
homepage "https://github.com/anomalyco/opencode"
|
||||
version "$OPENCODE_VERSION"
|
||||
license "MIT"
|
||||
|
||||
depends_on "ripgrep"
|
||||
conflicts_with "opencode", because: "both install an opencode binary"
|
||||
|
||||
on_macos do
|
||||
if Hardware::CPU.arm?
|
||||
url "$base/opencode-darwin-arm64.zip"
|
||||
sha256 "$(sum "$macos/opencode-darwin-arm64.zip")"
|
||||
else
|
||||
url "$base/opencode-darwin-x64-baseline.zip"
|
||||
sha256 "$(sum "$macos/opencode-darwin-x64-baseline.zip")"
|
||||
end
|
||||
end
|
||||
|
||||
on_linux do
|
||||
if Hardware::CPU.arm?
|
||||
url "$base/opencode-linux-arm64.tar.gz"
|
||||
sha256 "$(sum "$archives/opencode-linux-arm64.tar.gz")"
|
||||
else
|
||||
url "$base/opencode-linux-x64-baseline.tar.gz"
|
||||
sha256 "$(sum "$archives/opencode-linux-x64-baseline.tar.gz")"
|
||||
end
|
||||
end
|
||||
|
||||
def install
|
||||
bin.install "opencode"
|
||||
end
|
||||
end
|
||||
FORMULA
|
||||
cat "$tap/opencode-v2.rb"
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# render-winget.sh <sign-windows dir> <sign-desktop-windows-installer dir> <out dir>: writes the WinGet manifests for
|
||||
# Anomaly.OpenCode and Anomaly.OpenCode.Desktop. Submission to microsoft/winget-pkgs is paused until the packages
|
||||
# are accepted, so the workflow only uploads them.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
cli=$1 desktop=$2 out=$3
|
||||
sum() { sha256 "$1" | cut -c1-64 | tr a-f A-F; }
|
||||
base="https://opencode.ai/files/bin/$OPENCODE_VERSION"
|
||||
date=$(date -u +%F)
|
||||
header() {
|
||||
printf '# yaml-language-server: $schema=https://aka.ms/winget-manifest.%s.1.12.0.schema.json\n\nPackageIdentifier: %s\nPackageVersion: %s\n' \
|
||||
"$2" "$1" "$OPENCODE_VERSION"
|
||||
}
|
||||
footer() { printf 'ManifestType: %s\nManifestVersion: 1.12.0\n' "$1"; }
|
||||
manifests() {
|
||||
local id=$1 name=$2 description=$3 moniker=$4
|
||||
shift 4
|
||||
mkdir -p "$out/$id"
|
||||
{ header "$id" version; echo "DefaultLocale: en-US"; footer version; } > "$out/$id/$id.yaml"
|
||||
{ header "$id" installer; printf '%s\n' "$@" "ReleaseDate: $date"; footer installer; } > "$out/$id/$id.installer.yaml"
|
||||
{
|
||||
header "$id" defaultLocale
|
||||
printf '%s\n' "PackageLocale: en-US" "Publisher: OpenCode" "PublisherUrl: https://anoma.ly/" \
|
||||
"PublisherSupportUrl: https://github.com/anomalyco/opencode/issues" "PrivacyUrl: https://opencode.ai/legal/privacy-policy" \
|
||||
"PackageName: $name" "PackageUrl: https://opencode.ai/" "License: MIT" "LicenseUrl: https://github.com/anomalyco/opencode/blob/HEAD/LICENSE" \
|
||||
"ShortDescription: $description" "Moniker: $moniker" "Tags:" "- ai" "- coding-agent" "- developer-tools" \
|
||||
"Documentations:" "- DocumentLabel: Docs" " DocumentUrl: https://opencode.ai/v2/docs"
|
||||
footer defaultLocale
|
||||
} > "$out/$id/$id.locale.en-US.yaml"
|
||||
}
|
||||
|
||||
manifests Anomaly.OpenCode "OpenCode CLI" "The open source AI coding agent for the terminal." opencode \
|
||||
"InstallerType: zip" "NestedInstallerType: portable" "NestedInstallerFiles:" \
|
||||
"- RelativeFilePath: opencode.exe" " PortableCommandAlias: opencode" "Commands:" "- opencode" "Installers:" \
|
||||
"- Architecture: x64" " InstallerUrl: $base/opencode-windows-x64-baseline.zip" " InstallerSha256: $(sum "$cli/opencode-windows-x64-baseline.zip")" \
|
||||
"- Architecture: arm64" " InstallerUrl: $base/opencode-windows-arm64.zip" " InstallerSha256: $(sum "$cli/opencode-windows-arm64.zip")"
|
||||
|
||||
# The display name and uninstall key match what the NSIS installer registers for ai.opencode.desktop.
|
||||
manifests Anomaly.OpenCode.Desktop "OpenCode" "The open source AI coding agent as a desktop app." opencode-desktop \
|
||||
"InstallerType: nullsoft" "Scope: user" "UpgradeBehavior: install" "ProductCode: d074f30d-5f88-5885-b075-be1348cc7676" \
|
||||
"Protocols:" "- opencode" "Installers:" \
|
||||
"- Architecture: x64" " InstallerUrl: $base/opencode-desktop-win-x64.exe" " InstallerSha256: $(sum "$desktop/opencode-desktop-win-x64.exe")" \
|
||||
"- Architecture: arm64" " InstallerUrl: $base/opencode-desktop-win-arm64.exe" " InstallerSha256: $(sum "$desktop/opencode-desktop-win-arm64.exe")"
|
||||
tail -n +1 "$out"/*/*
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# repack-windows.sh <work dir> <out dir>: checks every signature in <work dir>, then writes the signed CLI back
|
||||
# into npm tarballs and opencode-<target>.zip archives in <out dir>.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
work=$(posix "$1") out=$(posix "$2")
|
||||
bash "$release_dir/verify-signatures-windows.sh" "$work"
|
||||
mkdir -p "$out"
|
||||
if [ ! -d "$work/cli" ]; then exit 0; fi
|
||||
for target in windows-arm64 windows-x64 windows-x64-baseline; do
|
||||
tar -czf "$out/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work/cli/$target" package
|
||||
powershell -NoProfile -Command "Compress-Archive -Path '$(cygpath -w "$work/cli/$target/package/bin/opencode.exe")' -DestinationPath '$(cygpath -w "$out/opencode-$target.zip")'"
|
||||
done
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
# sign-cli-macos.sh <build-npm dir> <out dir>: signs the three macOS CLI binaries inside their npm tarballs with
|
||||
# the Developer ID in build.keychain, then writes the re-packed tarballs and the opencode-<target>.zip archives.
|
||||
# Dry runs sign ad-hoc.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
in=$1 out=$2
|
||||
mkdir -p "$out"
|
||||
identity=- timestamp=--timestamp=none
|
||||
if ! dry_run; then
|
||||
identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1)
|
||||
[ -n "$identity" ] || die "Developer ID Application identity not found"
|
||||
timestamp=--timestamp
|
||||
fi
|
||||
|
||||
export COPYFILE_DISABLE=1
|
||||
for target in darwin-arm64 darwin-x64 darwin-x64-baseline; do
|
||||
work=$(mktemp -d)
|
||||
tar -xzf "$in/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work"
|
||||
bin="$work/package/bin/opencode"
|
||||
file -b "$bin" | grep -q '^Mach-O' || die "$target is not a Mach-O binary"
|
||||
chmod 755 "$bin"
|
||||
codesign --force "$timestamp" --options runtime --entitlements "$release_dir/entitlements/cli.plist" --sign "$identity" "$bin"
|
||||
codesign --verify --strict --verbose=2 "$bin"
|
||||
tar --no-mac-metadata -czf "$out/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work" package
|
||||
touch -t 198001010000 "$bin"
|
||||
(cd "$work/package/bin" && zip -X -q "$out/opencode-$target.zip" opencode)
|
||||
done
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
# sign-desktop-macos.sh <out dir> <app tarball>...: signs each unsigned .app inside-out with hardened runtime,
|
||||
# notarizes them in one submission, staples them, and only then builds opencode-desktop-mac-<arch>.{zip,dmg,app.tar.gz}
|
||||
# from the stapled apps. Dry runs sign ad-hoc and skip notarization. Beta trades larger files for faster packaging
|
||||
# (zip and dmg at zlib level 1) and skips the .app.tar.gz, which only the retired Tauri updater feed read.
|
||||
# Notarization reads APPLE_API_KEY_CONTENT, APPLE_API_KEY_ID and APPLE_API_ISSUER.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
out=$1
|
||||
shift
|
||||
mkdir -p "$out"
|
||||
apps=$(mktemp -d)
|
||||
identity=- timestamp=--timestamp=none
|
||||
zip_level=() dmg_level=()
|
||||
if [ "$OPENCODE_CHANNEL" = beta ]; then zip_level=(--zlibCompressionLevel 1) dmg_level=(-imagekey zlib-level=1); fi
|
||||
if ! dry_run; then
|
||||
identity=$(security find-identity -v -p codesigning build.keychain | sed -n 's/.*"\(Developer ID Application:.*\)"/\1/p' | head -n 1)
|
||||
[ -n "$identity" ] || die "Developer ID Application identity not found"
|
||||
timestamp=--timestamp
|
||||
fi
|
||||
sign() {
|
||||
codesign --force "$timestamp" --options runtime --entitlements "$2" --sign "$identity" "$1"
|
||||
}
|
||||
bundle() {
|
||||
find "$apps/$1" -mindepth 1 -maxdepth 1 -name '*.app' -type d
|
||||
}
|
||||
|
||||
for tarball in "$@"; do
|
||||
arch=$(basename "$tarball" .app.tar)
|
||||
arch=${arch#opencode-desktop-mac-}
|
||||
[ "$arch" = arm64 ] || [ "$arch" = x64 ] || die "Unexpected app tarball: $tarball"
|
||||
mkdir -p "$apps/$arch"
|
||||
tar -xf "$tarball" -C "$apps/$arch"
|
||||
if [ "$(find "$apps/$arch" -mindepth 1 -maxdepth 1 | wc -l | tr -d ' ')" != 1 ] || [ -z "$(bundle "$arch")" ]; then
|
||||
die "Expected exactly one .app bundle in $tarball"
|
||||
fi
|
||||
app=$(bundle "$arch")
|
||||
|
||||
# Every nested Mach-O file and bundle, deepest first, then the app itself.
|
||||
list=$(mktemp)
|
||||
{
|
||||
find "$app/Contents" -type f -print0 | while IFS= read -r -d '' file; do
|
||||
case "$(file -b --mime-type "$file")" in application/x-mach-binary*) printf '%s\n' "$file" ;; esac
|
||||
done
|
||||
find "$app/Contents" -type d \( -name '*.app' -o -name '*.framework' \) -print
|
||||
} | awk -F/ '{ print NF "\t" $0 }' | sort -t "$(printf '\t')" -k1,1nr | cut -f2- > "$list"
|
||||
echo "Signing $(wc -l < "$list" | tr -d ' ') items in $app"
|
||||
while IFS= read -r item; do
|
||||
if [ "$item" = "$app/Contents/Resources/opencode-cli" ]; then
|
||||
# The bundled Bun CLI loads bun-pty's native library; Electron and its helpers do not need this exception.
|
||||
sign "$item" "$release_dir/entitlements/desktop-cli.plist"
|
||||
else
|
||||
sign "$item" "$release_dir/entitlements/desktop.plist"
|
||||
fi
|
||||
done < "$list"
|
||||
sign "$app" "$release_dir/entitlements/desktop.plist"
|
||||
codesign --verify --deep --strict --verbose=2 "$app"
|
||||
done
|
||||
|
||||
if ! dry_run; then
|
||||
key=$(mktemp)
|
||||
printf '%s\n' "$APPLE_API_KEY_CONTENT" > "$key"
|
||||
ditto -c -k --sequesterRsrc "$apps" "$apps.zip"
|
||||
xcrun notarytool submit "$apps.zip" --key "$key" --key-id "$APPLE_API_KEY_ID" --issuer "$APPLE_API_ISSUER" \
|
||||
--wait --timeout 60m --output-format json > "$apps.json"
|
||||
rm -f "$key"
|
||||
cat "$apps.json"
|
||||
[ "$(jq -r .status "$apps.json")" = Accepted ] || die "Notarization was not accepted"
|
||||
fi
|
||||
|
||||
for dir in "$apps"/*; do
|
||||
arch=$(basename "$dir")
|
||||
app=$(bundle "$arch")
|
||||
name=$(basename "$app")
|
||||
if ! dry_run; then
|
||||
xcrun stapler staple "$app"
|
||||
xcrun stapler validate "$app"
|
||||
spctl --assess --type execute --verbose=2 "$app"
|
||||
fi
|
||||
ditto -c -k ${zip_level[@]+"${zip_level[@]}"} --sequesterRsrc --keepParent "$app" "$out/opencode-desktop-mac-$arch.zip"
|
||||
staging=$(mktemp -d)
|
||||
ditto "$app" "$staging/$name"
|
||||
ln -s /Applications "$staging/Applications"
|
||||
hdiutil create -volname "${name%.app}" -srcfolder "$staging" -fs HFS+ -format UDZO ${dmg_level[@]+"${dmg_level[@]}"} -ov "$out/opencode-desktop-mac-$arch.dmg"
|
||||
if [ "$OPENCODE_CHANNEL" = beta ]; then continue; fi
|
||||
COPYFILE_DISABLE=1 tar --no-mac-metadata -czf "$out/opencode-desktop-mac-$arch.app.tar.gz" -C "$dir" "$name"
|
||||
done
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# tag-release.sh: in a checkout of the dispatched dev commit, commits the release versions and changelog
|
||||
# (OPENCODE_RELEASE_NOTES) and pushes only the v<version> tag at it. Writes sha=<commit> to $GITHUB_OUTPUT.
|
||||
# Runs git only, with hooks disabled; no repository code.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
tag="v$OPENCODE_VERSION"
|
||||
git ls-files -z -- '*package.json' bun.lock | xargs -0 sed -i -E "s/\"version\": \"[^\"]+\"/\"version\": \"$OPENCODE_VERSION\"/g"
|
||||
|
||||
if [ -n "${OPENCODE_RELEASE_NOTES:-}" ] && ! grep -qF -x "## $tag" CHANGELOG.md && ! grep -qF "## $tag " CHANGELOG.md; then
|
||||
notes=$(mktemp)
|
||||
printf '%s\n' "$OPENCODE_RELEASE_NOTES" > "$notes"
|
||||
awk -v entry="## $tag — $(date -u +%F)" -v notes="$notes" '
|
||||
function emit() { print entry; print ""; while ((getline line < notes) > 0) print line; print ""; done = 1 }
|
||||
!done && /^## / { emit() }
|
||||
{ print }
|
||||
END { if (!done) { print ""; emit() } }
|
||||
' CHANGELOG.md > "$notes.md"
|
||||
mv "$notes.md" CHANGELOG.md
|
||||
fi
|
||||
|
||||
if git diff --name-only | grep -vE '(^|/)package\.json$|^bun\.lock$|^CHANGELOG\.md$'; then
|
||||
die "The release commit may only change versions and the changelog"
|
||||
fi
|
||||
|
||||
git -c core.hooksPath=/dev/null \
|
||||
-c user.name="github-actions[bot]" \
|
||||
-c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
|
||||
commit --no-verify -q -am "release: $tag"
|
||||
|
||||
# A rerun reuses the tag when it holds the same tree.
|
||||
existing=$(git ls-remote origin "refs/tags/$tag" | cut -f1)
|
||||
if [ -n "$existing" ]; then
|
||||
git fetch -q --depth=1 origin "refs/tags/$tag"
|
||||
[ "$(git rev-parse "$existing^{tree}")" = "$(git rev-parse "HEAD^{tree}")" ] || die "Tag $tag already exists with different contents"
|
||||
echo "sha=$existing" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
git push -q origin "HEAD:refs/tags/$tag"
|
||||
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env bash
|
||||
# unpack-windows.sh <download dir> <work dir>: lays out what the signing action signs in <work dir>:
|
||||
# cli/<target>/package from the Windows CLI npm tarballs, and desktop-<target>/ from the unpacked desktop apps.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
in=$(posix "$1") work=$(posix "$2")
|
||||
mkdir -p "$work"
|
||||
if [ -d "$in/build-npm" ]; then
|
||||
for target in windows-arm64 windows-x64 windows-x64-baseline; do
|
||||
mkdir -p "$work/cli/$target"
|
||||
tar -xzf "$in/build-npm/opencode-cli-$target-$OPENCODE_VERSION.tgz" -C "$work/cli/$target"
|
||||
test -s "$work/cli/$target/package/bin/opencode.exe" || die "Missing opencode.exe for $target"
|
||||
done
|
||||
fi
|
||||
for target in windows-arm64 windows-x64; do
|
||||
if [ -d "$in/build-desktop-$target" ]; then mkdir -p "$work/desktop-$target" && cp -R "$in/build-desktop-$target/app" "$work/desktop-$target/app"; fi
|
||||
done
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Upload a release artifact
|
||||
description: Writes SHA256SUMS for a directory, uploads it, and outputs the manifest digest.
|
||||
inputs:
|
||||
name:
|
||||
description: Artifact name, <stage>-<target>
|
||||
required: true
|
||||
path:
|
||||
description: Directory to upload
|
||||
required: true
|
||||
outputs:
|
||||
digest:
|
||||
description: SHA-256 of the artifact's SHA256SUMS
|
||||
value: ${{ steps.checksum.outputs.digest }}
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: checksum
|
||||
shell: bash
|
||||
run: echo "digest=$(bash "${GITHUB_ACTION_PATH//\\//}/../write-checksums.sh" "$UPLOAD_PATH")" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
UPLOAD_PATH: ${{ inputs.path }}
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: ${{ inputs.name }}
|
||||
path: ${{ inputs.path }}
|
||||
if-no-files-found: error
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# verify-artifacts.sh <dir>: checks every artifact downloaded into <dir>/<name> against its SHA256SUMS and that it
|
||||
# holds exactly the listed files. Artifacts made by sign jobs (sign-*) must also match the manifest digest their
|
||||
# job reported (OPENCODE_DIGESTS="name=digest ..."), so an artifact replaced after that job finished is rejected.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
root=$(posix "$1")
|
||||
for dir in "$root"/*/; do
|
||||
name=$(basename "$dir")
|
||||
digest=""
|
||||
for pair in ${OPENCODE_DIGESTS:-}; do
|
||||
if [ "${pair%%=*}" = "$name" ]; then digest=${pair#*=}; fi
|
||||
done
|
||||
case "$name" in sign-*) [[ "$digest" =~ ^[0-9a-f]{64}$ ]] || die "Missing digest for $name" ;; esac
|
||||
(
|
||||
cd "$dir"
|
||||
if [ -n "$digest" ] && [ "$(sha256 SHA256SUMS | cut -c1-64)" != "$digest" ]; then die "SHA256SUMS digest mismatch in $name"; fi
|
||||
sha256 -c SHA256SUMS > /dev/null || die "Checksum mismatch in $name"
|
||||
diff <(find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort) <(cut -c67- SHA256SUMS | LC_ALL=C sort) ||
|
||||
die "Unexpected files in $name"
|
||||
)
|
||||
echo "verified $name${digest:+ ($digest)}"
|
||||
done
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# verify-signatures-windows.sh <dir>: fails unless every .exe and .node under <dir> has a valid Authenticode signature.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
if dry_run; then
|
||||
echo "dry-run: not verifying signatures in $1"
|
||||
exit 0
|
||||
fi
|
||||
powershell -NoProfile -Command "
|
||||
\$ErrorActionPreference = 'Stop'
|
||||
\$files = Get-ChildItem '$(cygpath -w "$(posix "$1")")' -Recurse -Include *.exe, *.node
|
||||
if (-not \$files) { throw 'No signed files found' }
|
||||
foreach (\$file in \$files) {
|
||||
\$sig = Get-AuthenticodeSignature \$file.FullName
|
||||
if (\$sig.Status -ne 'Valid') { throw \"Invalid signature for \$(\$file.FullName): \$(\$sig.Status)\" }
|
||||
}
|
||||
Write-Output \"verified \$(\$files.Count) signatures\"
|
||||
"
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# write-checksums.sh <dir>: writes <dir>/SHA256SUMS for every file under <dir> and prints its digest.
|
||||
# Every artifact carries this manifest; trusted jobs pass the digest on through job outputs.
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
|
||||
cd "$(posix "$1")"
|
||||
manifest=$(mktemp)
|
||||
find . -type f ! -name SHA256SUMS | sed 's|^\./||' | LC_ALL=C sort | while IFS= read -r file; do sha256 "$file"; done > "$manifest"
|
||||
mv "$manifest" SHA256SUMS
|
||||
cat SHA256SUMS >&2
|
||||
sha256 SHA256SUMS | cut -c1-64
|
||||
@@ -12,6 +12,7 @@ jobs:
|
||||
if: false
|
||||
#if: github.actor != 'opencode-agent[bot]'
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: release
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: bot-nix-hashes
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -91,6 +91,7 @@ jobs:
|
||||
needs: compute-hash
|
||||
if: github.event_name != 'pull_request'
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: release
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
||||
@@ -119,10 +119,10 @@ jobs:
|
||||
TURBO_SCM_BASE: ${{ github.event_name == 'pull_request' && format('{0}^1', github.sha) || github.event.before }}
|
||||
TURBO_SCM_HEAD: ${{ github.sha }}
|
||||
|
||||
- name: Verify published codemode package
|
||||
- name: Verify packed codemode package
|
||||
if: runner.os == 'Linux'
|
||||
working-directory: packages/codemode
|
||||
run: bun run script/publish.ts --dry-run
|
||||
run: bun run pack
|
||||
|
||||
- name: Verify packed workerd SDK
|
||||
if: runner.os == 'Linux'
|
||||
|
||||
@@ -20,6 +20,7 @@ jobs:
|
||||
deploy:
|
||||
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'dev'
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: release
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
deploy:
|
||||
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: ${{ github.ref_name == 'production' && 'production' || '' }}
|
||||
environment: ${{ github.ref_name == 'production' && 'production' || 'release' }}
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
deploy:
|
||||
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production')
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: ${{ github.ref_name == 'production' && 'production' || '' }}
|
||||
environment: ${{ github.ref_name == 'production' && 'production' || 'release' }}
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
|
||||
@@ -12,13 +12,16 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: github.repository == 'anomalyco/opencode' && (github.ref_name == 'dev' || github.ref_name == 'production' || github.ref_name == 'beta')
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: ${{ github.ref_name }}
|
||||
# production keeps its own environment so dev and beta pushes can never reach production credentials.
|
||||
environment: ${{ github.ref_name == 'production' && 'production' || 'release' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
name: notify-discord
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released] # fires when a draft release is published
|
||||
|
||||
jobs:
|
||||
notify:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
steps:
|
||||
- name: Send nicely-formatted embed to Discord
|
||||
uses: SethCohen/github-releases-to-discord@24d166886aee4646d448c8a389ff9e1ebcab3682 # v1.20.0
|
||||
with:
|
||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
@@ -1,38 +0,0 @@
|
||||
name: publish-vscode
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "vscode-v*.*.*"
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
environment: release
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- run: git fetch --force --tags
|
||||
- run: bun install -g @vscode/vsce
|
||||
|
||||
- name: Install extension dependencies
|
||||
run: bun install
|
||||
working-directory: ./sdks/vscode
|
||||
|
||||
- name: Publish
|
||||
run: |
|
||||
./script/publish
|
||||
working-directory: ./sdks/vscode
|
||||
env:
|
||||
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
||||
OPENVSX_TOKEN: ${{ secrets.OPENVSX_TOKEN }}
|
||||
@@ -1,910 +0,0 @@
|
||||
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:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ (github.ref_name == 'dev' && (inputs.version || inputs.bump) && 'release') || inputs.version || inputs.bump }}
|
||||
# Beta ships only the newest commit to the team. A cancelled beta run can leave unreferenced files in R2, but only
|
||||
# its publish job records a release, in one request.
|
||||
cancel-in-progress: ${{ github.ref_name == 'beta' }}
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: write
|
||||
packages: write
|
||||
# Beta desktop jobs poll this run's artifacts while the CLI builds.
|
||||
actions: read
|
||||
# Beta desktop builds read who made each change and what it does for "What's new in beta".
|
||||
pull-requests: 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'
|
||||
# Versioned releases wait for approval in the release environment, which only allows dev.
|
||||
environment: ${{ (inputs.bump || inputs.version) && 'release' || '' }}
|
||||
env:
|
||||
BETA: ${{ github.ref_name == 'beta' }}
|
||||
steps:
|
||||
# A beta version only depends on the run number, so beta computes it without a checkout or an install.
|
||||
- name: Beta version
|
||||
id: beta
|
||||
if: env.BETA == 'true'
|
||||
run: |
|
||||
# Matches packages/script: 0.0.0-<channel>-<run number>[.<attempt>] for preview channels.
|
||||
version="0.0.0-beta-${GITHUB_RUN_NUMBER}"
|
||||
if [ "$GITHUB_RUN_ATTEMPT" != "1" ]; then version="${version}.${GITHUB_RUN_ATTEMPT}"; fi
|
||||
{
|
||||
echo "version=$version"
|
||||
echo "release=true"
|
||||
echo "tag=v$version"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
if: env.BETA != 'true'
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
if: env.BETA != 'true'
|
||||
|
||||
- name: Setup git committer
|
||||
id: committer
|
||||
if: env.BETA != 'true'
|
||||
uses: ./.github/actions/setup-git-committer
|
||||
with:
|
||||
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
|
||||
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||
|
||||
- name: Install OpenCode
|
||||
if: inputs.bump || inputs.version
|
||||
run: bun i -g opencode-ai
|
||||
|
||||
- id: version
|
||||
if: env.BETA != 'true'
|
||||
run: |
|
||||
./script/version.ts
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
||||
OPENCODE_BUMP: ${{ inputs.bump }}
|
||||
OPENCODE_VERSION: ${{ inputs.version }}
|
||||
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version || steps.beta.outputs.version }}
|
||||
release: ${{ steps.version.outputs.release || steps.beta.outputs.release }}
|
||||
tag: ${{ steps.version.outputs.tag || steps.beta.outputs.tag }}
|
||||
|
||||
models-catalog:
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
if: github.repository == 'anomalyco/opencode'
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- name: Fetch models.dev catalog
|
||||
run: bun packages/core/script/update-models-snapshot.ts .cache/models-catalog/api.json
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog/api.json
|
||||
if-no-files-found: error
|
||||
|
||||
build-cli:
|
||||
needs:
|
||||
- version
|
||||
- models-catalog
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
# Beta builds only the CLIs its desktop app bundles, in build-cli-beta.
|
||||
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta'
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
with:
|
||||
fetch-tags: true
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: 1.4.4
|
||||
|
||||
- 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 }}
|
||||
|
||||
- name: Build legacy CLI
|
||||
if: github.ref_name != 'dev' && github.ref_name != 'beta'
|
||||
run: ./packages/opencode/script/build.ts ${{ (github.ref_name == 'beta' && '--sourcemaps') || '' }}
|
||||
env:
|
||||
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
||||
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
||||
|
||||
- name: Build preview CLI
|
||||
id: build
|
||||
run: ./packages/cli/script/build.ts ${{ (github.ref_name == 'beta' && '--sourcemaps') || '' }}
|
||||
env:
|
||||
BUN_COMPILE_RELEASE: bun-v1.4.4
|
||||
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.committer.outputs.token }}
|
||||
|
||||
- name: Verify bundled models catalog
|
||||
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64/bin/opencode
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.ref_name != 'dev' && github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-cli
|
||||
path: |
|
||||
packages/opencode/dist/opencode-darwin*
|
||||
packages/opencode/dist/opencode-linux*
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.ref_name != 'dev' && github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-cli-windows
|
||||
path: packages/opencode/dist/opencode-windows*
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: opencode-preview-cli-unsigned
|
||||
path: packages/cli/dist/cli-*
|
||||
|
||||
outputs:
|
||||
version: ${{ needs.version.outputs.version }}
|
||||
|
||||
# Beta publishes only the desktop app, so it builds just the 6 CLIs the desktop bundles, each in its own job and
|
||||
# artifact. Desktop jobs start alongside and wait for their CLI only when they need it.
|
||||
build-cli-beta:
|
||||
needs:
|
||||
- version
|
||||
- models-catalog
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
if: github.repository == 'anomalyco/opencode' && github.ref_name == 'beta'
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# macOS first: notarization makes those desktop jobs the longest.
|
||||
target:
|
||||
- darwin-x64-baseline
|
||||
- darwin-arm64
|
||||
- linux-arm64
|
||||
- windows-arm64
|
||||
- windows-x64-baseline
|
||||
- linux-x64-baseline
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: 1.4.4
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
|
||||
- name: Build CLI
|
||||
run: ./packages/cli/script/build.ts --target=opencode-${{ matrix.target }}
|
||||
env:
|
||||
BUN_COMPILE_RELEASE: bun-v1.4.4
|
||||
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
||||
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Verify bundled models catalog
|
||||
if: matrix.target == 'linux-x64-baseline'
|
||||
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64-baseline/bin/opencode
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: opencode-cli-unsigned-cli-${{ matrix.target }}
|
||||
path: packages/cli/dist/cli-${{ matrix.target }}
|
||||
# Deflate level 1 compresses a CLI binary twice as fast as the default for 7% more bytes.
|
||||
compression-level: 1
|
||||
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:
|
||||
name: opencode-preview-cli-unsigned
|
||||
path: packages/cli/dist
|
||||
|
||||
- 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: opencode-preview-cli-macos
|
||||
path: packages/cli/dist/cli-*
|
||||
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
|
||||
- models-catalog
|
||||
- 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 }}
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
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
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
|
||||
- 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
|
||||
|
||||
- name: Verify bundled models catalog
|
||||
if: matrix.settings.target != 'windows-arm64'
|
||||
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/node/cli-node-${{ matrix.settings.target }}/bin/opencode2-node${{ startsWith(matrix.settings.target, 'windows') && '.exe' || '' }}
|
||||
|
||||
- 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:
|
||||
- sign-cli-macos
|
||||
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/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: opencode-preview-cli-macos
|
||||
path: packages/cli/dist
|
||||
|
||||
- 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: opencode-preview-cli
|
||||
path: packages/cli/dist/cli-*
|
||||
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.
|
||||
# Beta skips build-cli and waits for its own CLI from build-cli-beta just before Prepare.
|
||||
needs:
|
||||
- version
|
||||
- build-cli
|
||||
if: ${{ !cancelled() && !failure() && 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:
|
||||
# Beta packages macOS x64 on Apple Silicon and Windows arm64 on Blacksmith. electron-builder's afterPack rejects
|
||||
# a bundle whose CLI or node-pty does not match the target CPU.
|
||||
settings:
|
||||
- host: ${{ (github.ref_name == 'beta' && 'macos-26') || 'macos-26-intel' }}
|
||||
target: x86_64-apple-darwin
|
||||
cli: darwin-x64-baseline
|
||||
platform_flag: --mac --x64
|
||||
bun_install_flags: ${{ (github.ref_name == 'beta' && '--os=darwin --cpu=*') || '--os=darwin --cpu=x64' }}
|
||||
- host: macos-26
|
||||
target: aarch64-apple-darwin
|
||||
cli: darwin-arm64
|
||||
platform_flag: --mac --arm64
|
||||
bun_install_flags: --os=darwin --cpu=arm64
|
||||
# Releases keep github-hosted Windows from the Tauri build, which needed an ARM64 MSVC toolchain; Electron
|
||||
# packaging compiles nothing.
|
||||
- host: ${{ (github.ref_name == 'beta' && 'blacksmith-4vcpu-windows-2025') || '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: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-preview-cli-unsigned
|
||||
path: packages/cli/dist
|
||||
|
||||
- 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 }}
|
||||
|
||||
- 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 }}
|
||||
|
||||
- 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 }}
|
||||
|
||||
# Beta trades larger installers for faster packaging. These variables must stay unset elsewhere:
|
||||
# electron-builder rejects an empty ELECTRON_BUILDER_COMPRESSION_LEVEL.
|
||||
- name: Beta packaging settings
|
||||
if: github.ref_name == 'beta'
|
||||
shell: bash
|
||||
run: |
|
||||
# fpm sets XZ_OPT for the deb and rpm level, but xz still reads XZ_DEFAULTS, so it uses every CPU.
|
||||
if [ "$RUNNER_OS" = "Linux" ]; then echo "XZ_DEFAULTS=-T0" >> "$GITHUB_ENV"; fi
|
||||
# The macOS zip (7z deflate, default -mx=7) and DMG (UDZO zlib, default level 9) at level 1.
|
||||
if [ "$RUNNER_OS" = "macOS" ]; then echo "ELECTRON_BUILDER_COMPRESSION_LEVEL=1" >> "$GITHUB_ENV"; fi
|
||||
|
||||
# The beta build embeds the subjects of its newest commits for "What's new in beta"
|
||||
# (packages/desktop/scripts/beta-notes.ts), with their pull requests' authors and descriptions from GitHub.
|
||||
# Commits without file contents are enough.
|
||||
- name: Fetch beta history (beta)
|
||||
if: github.ref_name == 'beta'
|
||||
shell: bash
|
||||
run: git fetch --no-tags --filter=blob:none --depth=300 origin "$GITHUB_SHA"
|
||||
|
||||
# Beta builds the app 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 (beta)
|
||||
if: github.ref_name == 'beta'
|
||||
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: beta
|
||||
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: beta
|
||||
VITE_SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
|
||||
OPENCODE_CLI_TARGET: ${{ matrix.settings.target }}
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Wait for the CLI (beta)
|
||||
if: github.ref_name == 'beta'
|
||||
run: bun ./script/wait-for-artifact.ts opencode-cli-unsigned-cli-${{ matrix.settings.cli }} "build-cli-beta (${{ matrix.settings.cli }})"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ github.token }}
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name == 'beta'
|
||||
with:
|
||||
name: opencode-cli-unsigned-cli-${{ matrix.settings.cli }}
|
||||
path: packages/cli/dist/cli-${{ matrix.settings.cli }}
|
||||
|
||||
- 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
|
||||
|
||||
- name: Build
|
||||
if: github.ref_name != 'beta'
|
||||
run: bun run 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 }}
|
||||
OPENCODE_CLI_DIST: ${{ github.workspace }}/packages/cli/dist
|
||||
|
||||
- name: Package
|
||||
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 }}
|
||||
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
|
||||
# Only the retired Tauri updater feed read these archives.
|
||||
if: runner.os == 'macOS' && needs.version.outputs.release && github.ref_name != 'beta'
|
||||
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)"
|
||||
}
|
||||
}
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-desktop-${{ matrix.settings.target }}
|
||||
path: packages/desktop/dist/*
|
||||
|
||||
# Beta uploads its installers to R2 here instead of passing them through an artifact to publish, which only
|
||||
# records the release from the returned file list.
|
||||
- name: Upload to R2 (beta)
|
||||
if: github.ref_name == 'beta'
|
||||
run: bun ./scripts/upload.ts dist dist/uploaded-${{ matrix.settings.target }}.json
|
||||
working-directory: packages/desktop
|
||||
env:
|
||||
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
|
||||
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.ref_name == 'beta'
|
||||
with:
|
||||
name: desktop-uploaded-${{ matrix.settings.target }}
|
||||
path: packages/desktop/dist/uploaded-${{ matrix.settings.target }}.json
|
||||
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
|
||||
|
||||
publish:
|
||||
needs:
|
||||
- version
|
||||
- models-catalog
|
||||
- build-cli
|
||||
- build-cli-beta
|
||||
- sign-cli-macos
|
||||
- build-node-app-archive
|
||||
- build-node-cli
|
||||
- sign-cli-windows
|
||||
- build-electron
|
||||
if: always() && !failure() && !cancelled()
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
# Versioned and beta releases wait for approval in the release environment; dev previews do not.
|
||||
environment: ${{ needs.version.outputs.release && 'release' || '' }}
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
steps:
|
||||
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||
|
||||
- uses: ./.github/actions/setup-bun
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
|
||||
# Beta only records the desktop release, so it skips the Docker, git and AUR setup.
|
||||
- name: Login to GitHub Container Registry
|
||||
if: github.ref_name != 'beta'
|
||||
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: github.ref_name != 'beta'
|
||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
if: github.ref_name != 'beta'
|
||||
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 != 'dev' && github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-cli
|
||||
path: packages/opencode/dist
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name != 'dev' && github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-cli-windows
|
||||
path: packages/opencode/dist
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name != 'dev' && github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-cli-signed-windows
|
||||
path: packages/opencode/dist
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name != 'beta'
|
||||
with:
|
||||
name: opencode-preview-cli
|
||||
path: packages/cli/dist
|
||||
|
||||
- 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
|
||||
|
||||
- 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 && github.ref_name != 'beta'
|
||||
with:
|
||||
pattern: opencode-desktop-*
|
||||
path: /tmp/desktop
|
||||
merge-multiple: true
|
||||
|
||||
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: github.ref_name == 'beta'
|
||||
with:
|
||||
pattern: desktop-uploaded-*
|
||||
path: /tmp/desktop-uploaded
|
||||
merge-multiple: true
|
||||
|
||||
- name: Setup git committer
|
||||
id: committer
|
||||
if: github.ref_name != 'beta'
|
||||
uses: ./.github/actions/setup-git-committer
|
||||
with:
|
||||
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
|
||||
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||
|
||||
- name: Cache apt packages (AUR)
|
||||
if: github.ref_name != 'beta'
|
||||
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: github.ref_name != 'beta'
|
||||
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_DESKTOP_UPLOADED: ${{ (github.ref_name == 'beta' && '/tmp/desktop-uploaded') || '' }}
|
||||
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
|
||||
environment: release
|
||||
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 }}
|
||||
@@ -0,0 +1,727 @@
|
||||
name: release-dry-run
|
||||
run-name: "${{ format('release {0}{1}', inputs.bump, inputs.version) }}"
|
||||
|
||||
# Builds are separated from signing and publishing.
|
||||
# - build-* jobs run repository code (`bun run build`, `bun run pack`) with no environment, secrets or id-token.
|
||||
# - sign-* and publish-* jobs run in the release environment, check out only .github/release/, and run those
|
||||
# scripts on verified artifacts, which they treat as data. They never execute repository code.
|
||||
# - plan decides version, channel and npm dist-tag from the event, inputs and ref; only a dispatch with a bump or
|
||||
# version on dev reaches latest.
|
||||
# .github/release/ and this file are the security boundary for releases.
|
||||
|
||||
# TEMPORARY copy of release.yml for this PR's dry run: GitHub does not start runs for the release.yml path on
|
||||
# pull requests (it is the old name of publish.yml). Delete before merging.
|
||||
on:
|
||||
pull_request:
|
||||
paths: [.github/workflows/release.yml, .github/workflows/release-dry-run.yml, .github/release/**]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ (inputs.bump || inputs.version) && 'release' || 'build' }}
|
||||
# Beta ships only the newest commit to the team. A cancelled beta run can leave unreferenced files in R2, but only
|
||||
# publish-desktop records a release, in one request.
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref_name == 'beta' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
if: github.repository == 'anomalyco/opencode'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: {}
|
||||
outputs:
|
||||
version: ${{ steps.plan.outputs.version }}
|
||||
channel: ${{ steps.plan.outputs.channel }}
|
||||
npm_tag: ${{ steps.plan.outputs.npm_tag }}
|
||||
dry_run: ${{ steps.plan.outputs.dry_run }}
|
||||
cli: ${{ steps.plan.outputs.cli }}
|
||||
desktop: ${{ steps.plan.outputs.desktop }}
|
||||
node: ${{ steps.plan.outputs.node }}
|
||||
release: ${{ steps.plan.outputs.release }}
|
||||
steps:
|
||||
- &checkout-release
|
||||
name: Check out release scripts
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
sparse-checkout: /.github/release/
|
||||
sparse-checkout-cone-mode: false
|
||||
persist-credentials: false
|
||||
- id: plan
|
||||
name: Plan
|
||||
run: bash .github/release/plan-release.sh
|
||||
env:
|
||||
INPUT_BUMP: ${{ inputs.bump }}
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
|
||||
# A versioned release builds from a commit with its versions and changelog on the dispatched dev commit,
|
||||
# tagged v<version>. Runs git only.
|
||||
tag:
|
||||
needs: plan
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
env: &env
|
||||
OPENCODE_VERSION: ${{ needs.plan.outputs.version }}
|
||||
OPENCODE_CHANNEL: ${{ needs.plan.outputs.channel }}
|
||||
OPENCODE_NPM_TAG: ${{ needs.plan.outputs.npm_tag }}
|
||||
OPENCODE_DRY_RUN: ${{ needs.plan.outputs.dry_run }}
|
||||
outputs:
|
||||
sha: ${{ steps.tag.outputs.sha || github.sha }}
|
||||
steps:
|
||||
- name: Check out
|
||||
if: needs.plan.outputs.channel == 'latest'
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
- id: tag
|
||||
name: Tag
|
||||
if: needs.plan.outputs.channel == 'latest'
|
||||
run: bash .github/release/tag-release.sh
|
||||
env:
|
||||
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
|
||||
|
||||
# ---- Build: repository code; no environment, secrets or id-token --------------------------------------------
|
||||
|
||||
# Fetches the models.dev catalog once per run, so every CLI bundles the same copy.
|
||||
models-catalog:
|
||||
needs: [plan, tag]
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env: *env
|
||||
steps:
|
||||
- &checkout
|
||||
name: Check out
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
with:
|
||||
ref: ${{ needs.tag.outputs.sha }}
|
||||
persist-credentials: false
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Fetch
|
||||
run: bun packages/core/script/update-models-snapshot.ts .cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog/api.json
|
||||
if-no-files-found: error
|
||||
|
||||
build-cli:
|
||||
needs: [plan, tag, models-catalog]
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: 1.4.4
|
||||
- &download-models-catalog
|
||||
name: Download models catalog
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
- name: Build
|
||||
working-directory: packages/cli
|
||||
run: bun run build && rm -rf dist/.bun
|
||||
env:
|
||||
BUN_COMPILE_RELEASE: bun-v1.4.4
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
OPENCODE_RELEASE_NOTES: ${{ needs.plan.outputs.channel == 'latest' && inputs.release_notes || '' }}
|
||||
GH_TOKEN: ${{ github.token }} # read-only; raises the rate limit for Bun release downloads
|
||||
- name: Verify bundled models catalog
|
||||
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64/bin/opencode
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-cli
|
||||
path: packages/cli/dist
|
||||
|
||||
build-node:
|
||||
needs: [plan, tag, models-catalog]
|
||||
if: needs.plan.outputs.node == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { 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 }
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "26.4.0"
|
||||
- *download-models-catalog
|
||||
- name: Build
|
||||
working-directory: packages/cli
|
||||
run: bun run build:node
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Test
|
||||
if: matrix.target != 'windows-arm64'
|
||||
working-directory: packages/cli
|
||||
run: bun run script/service-smoke.ts --node
|
||||
- name: Verify bundled models catalog
|
||||
if: matrix.target != 'windows-arm64'
|
||||
run: bun packages/cli/script/catalog-smoke.ts "packages/cli/dist/node/cli-node-$OPENCODE_TARGET/bin/opencode2-node$EXE"
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
EXE: ${{ startsWith(matrix.target, 'windows') && '.exe' || '' }}
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-node-${{ matrix.target }}
|
||||
path: packages/cli/dist/node
|
||||
|
||||
# `bun run pack` packs every npm package into dist/npm and the Linux and Node CLI archives into dist/archives.
|
||||
# The macOS and Windows CLI packages and archives are re-packed after signing.
|
||||
build-npm:
|
||||
needs: [plan, tag, build-cli, build-node]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- &download-cli
|
||||
name: Download
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-cli
|
||||
path: packages/cli/dist
|
||||
- name: Download Node CLI
|
||||
if: needs.plan.outputs.node == 'true'
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: build-node-*
|
||||
path: packages/cli/dist/node
|
||||
merge-multiple: true
|
||||
- name: Pack
|
||||
run: rm packages/cli/dist/SHA256SUMS && bun run pack
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-npm
|
||||
path: dist/npm
|
||||
- name: Upload archives
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-archives
|
||||
path: dist/archives
|
||||
|
||||
build-docker:
|
||||
needs: [plan, tag, build-cli]
|
||||
if: needs.plan.outputs.release == 'true'
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- *download-cli
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
- name: Set up Buildx
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Pack
|
||||
working-directory: packages/cli
|
||||
run: bun run pack:docker
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-docker
|
||||
path: dist/docker
|
||||
|
||||
# macOS and Windows pack an unsigned app; Linux packs the final AppImage, deb and rpm.
|
||||
# Beta packages macOS x64 on Apple Silicon and Windows arm64 on Blacksmith for speed. electron-builder's afterPack
|
||||
# rejects a bundle whose CLI or node-pty does not match the target CPU.
|
||||
build-desktop:
|
||||
needs: [plan, tag, build-cli]
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read # beta builds read who made each change and what it does for "What's new in beta"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: darwin-x64
|
||||
host: ${{ github.ref_name == 'beta' && 'macos-26' || 'macos-26-intel' }}
|
||||
install: ${{ github.ref_name == 'beta' && '--os=darwin --cpu=*' || '--os=darwin --cpu=x64' }}
|
||||
- { target: darwin-arm64, host: macos-26, install: --os=darwin --cpu=arm64 }
|
||||
# github-hosted: blacksmith lacks the ARM64 MSVC cross-compilation toolchain
|
||||
- target: windows-arm64
|
||||
host: ${{ github.ref_name == 'beta' && 'blacksmith-4vcpu-windows-2025' || 'windows-2025' }}
|
||||
install: --cpu=*
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
- { target: linux-x64, host: blacksmith-4vcpu-ubuntu-2404 }
|
||||
- { target: linux-arm64, host: blacksmith-4vcpu-ubuntu-2404-arm }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- *download-cli
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
install-flags: ${{ matrix.install }}
|
||||
- name: Set up rpm
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends rpm
|
||||
# The beta build embeds the subjects of its newest commits for "What's new in beta"
|
||||
# (packages/desktop/script/beta-notes.ts). Commits without file contents are enough.
|
||||
- name: Fetch beta history
|
||||
if: needs.plan.outputs.channel == 'beta'
|
||||
run: git fetch --no-tags --filter=blob:none --depth=300 origin "$SHA"
|
||||
env:
|
||||
SHA: ${{ needs.tag.outputs.sha }}
|
||||
# Beta trades larger packages for faster packaging. fpm sets XZ_OPT for the deb and rpm level, but xz still
|
||||
# reads XZ_DEFAULTS, so it uses every CPU.
|
||||
- name: Beta packaging settings
|
||||
if: needs.plan.outputs.channel == 'beta' && runner.os == 'Linux'
|
||||
run: echo "XZ_DEFAULTS=-T0" >> "$GITHUB_ENV"
|
||||
- name: Build
|
||||
working-directory: packages/desktop
|
||||
run: bun run build
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
|
||||
VITE_SENTRY_ENVIRONMENT: ${{ needs.plan.outputs.channel == 'beta' && 'beta' || 'production' }}
|
||||
VITE_SENTRY_RELEASE: desktop@${{ needs.plan.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ github.token }} # read-only; beta notes read pull request authors and descriptions
|
||||
- name: Pack
|
||||
working-directory: packages/desktop
|
||||
timeout-minutes: 60
|
||||
run: bun run pack
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-desktop-${{ matrix.target }}
|
||||
path: dist/desktop
|
||||
|
||||
# Packs the NSIS installer around the signed app. This runs repository config, so it is a build job; the
|
||||
# installer is signed next.
|
||||
build-desktop-windows-installer:
|
||||
needs: [plan, tag, sign-windows]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: windows-arm64
|
||||
host: ${{ github.ref_name == 'beta' && 'blacksmith-4vcpu-windows-2025' || 'windows-2025' }}
|
||||
install: --cpu=*
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
install-flags: ${{ matrix.install }}
|
||||
- name: Download
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: sign-desktop-${{ matrix.target }}
|
||||
path: ${{ runner.temp }}/app
|
||||
- name: Pack
|
||||
working-directory: packages/desktop
|
||||
timeout-minutes: 30
|
||||
run: bun run pack
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
OPENCODE_DESKTOP_APP: ${{ runner.temp }}/app/app
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-desktop-windows-installer-${{ matrix.target }}
|
||||
path: dist/desktop
|
||||
|
||||
# ---- Sign: release environment; only .github/release/ is checked out ----------------------------------------
|
||||
# Pull requests run sign and publish jobs without an environment, so steps that need a secret skip or dry-run.
|
||||
|
||||
# Signs the macOS CLI; signs the desktop apps inside-out, notarizes them in one submission, staples them, and
|
||||
# only then builds the zip, dmg and .app.tar.gz from the stapled apps.
|
||||
sign-macos:
|
||||
needs: [plan, build-npm, build-desktop]
|
||||
if: ${{ !cancelled() && !failure() && (needs.plan.outputs.cli == 'true' || needs.plan.outputs.desktop == 'true') }}
|
||||
runs-on: macos-26
|
||||
timeout-minutes: 90
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-desktop-darwin-*}"
|
||||
- name: Import certificate
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
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 }}
|
||||
- name: Sign CLI
|
||||
if: needs.plan.outputs.cli == 'true'
|
||||
run: bash .github/release/sign-cli-macos.sh "$RUNNER_TEMP/in/build-npm" "$RUNNER_TEMP/out"
|
||||
- name: Sign desktop
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
run: |
|
||||
bash .github/release/sign-desktop-macos.sh "$RUNNER_TEMP/out" \
|
||||
"$RUNNER_TEMP"/in/build-desktop-darwin-*/opencode-desktop-mac-*.app.tar
|
||||
env:
|
||||
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_PATH }}
|
||||
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
|
||||
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
||||
- id: upload
|
||||
name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-macos
|
||||
path: ${{ runner.temp }}/out
|
||||
|
||||
# Signs the Windows CLI and every executable and native module of the unpacked desktop apps.
|
||||
sign-windows:
|
||||
needs: [plan, build-npm, build-desktop]
|
||||
if: ${{ !cancelled() && !failure() && (needs.plan.outputs.cli == 'true' || needs.plan.outputs.desktop == 'true') }}
|
||||
runs-on: windows-2025
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-desktop-windows-*}"
|
||||
- name: Unpack
|
||||
run: bash .github/release/unpack-windows.sh "$RUNNER_TEMP/in" "$RUNNER_TEMP/work"
|
||||
- &azure-login
|
||||
name: Log in to Azure
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
- &azure-sign
|
||||
name: Sign
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: azure/artifact-signing-action@b443cf8ea4124818d2ea9f043cba29fc3ec47b16 # v1.2.0
|
||||
with:
|
||||
endpoint: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
||||
signing-account-name: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
||||
certificate-profile-name: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
||||
files-folder: ${{ runner.temp }}\work
|
||||
files-folder-filter: exe,node
|
||||
files-folder-recurse: true
|
||||
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: Repack
|
||||
run: bash .github/release/repack-windows.sh "$RUNNER_TEMP/work" "$RUNNER_TEMP/out"
|
||||
- id: upload
|
||||
name: Upload
|
||||
if: needs.plan.outputs.cli == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-windows
|
||||
path: ${{ runner.temp }}/out
|
||||
- name: Upload arm64 app
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-arm64
|
||||
path: ${{ runner.temp }}/work/desktop-windows-arm64
|
||||
- name: Upload x64 app
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-x64
|
||||
path: ${{ runner.temp }}/work/desktop-windows-x64
|
||||
|
||||
sign-desktop-windows-installer:
|
||||
needs: [plan, build-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
runs-on: windows-2025
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: build-desktop-windows-installer-*
|
||||
- name: Unpack
|
||||
run: mkdir -p "$RUNNER_TEMP/work" && cp "$RUNNER_TEMP"/in/build-desktop-windows-installer-*/*.exe "$RUNNER_TEMP/work/"
|
||||
- *azure-login
|
||||
- *azure-sign
|
||||
- name: Repack
|
||||
run: bash .github/release/repack-windows.sh "$RUNNER_TEMP/work" "$RUNNER_TEMP/out"
|
||||
- id: upload
|
||||
name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-installer
|
||||
path: ${{ runner.temp }}/work
|
||||
|
||||
# ---- Publish: release environment; only .github/release/ is checked out -------------------------------------
|
||||
# Destinations, names and channels come from plan and the scripts, never from artifacts.
|
||||
|
||||
# Build provenance for the npm tarballs and Linux archives. No secrets; id-token only for Sigstore.
|
||||
publish-attestations:
|
||||
needs: [plan, build-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' && needs.plan.outputs.dry_run != 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: write
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-archives}"
|
||||
- name: Sign
|
||||
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
||||
with:
|
||||
subject-path: |
|
||||
${{ runner.temp }}/in/build-npm/*.tgz
|
||||
${{ runner.temp }}/in/build-archives/opencode*
|
||||
|
||||
publish-npm:
|
||||
needs: [plan, sign-macos, sign-windows, publish-attestations]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: read
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24.11.0"
|
||||
- &download-signed-cli
|
||||
name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-archives,sign-macos,sign-windows}"
|
||||
digests: sign-macos=${{ needs.sign-macos.outputs.digest }} sign-windows=${{ needs.sign-windows.outputs.digest }}
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-npm.sh "$RUNNER_TEMP/in/build-npm" "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-windows"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
publish-cli:
|
||||
needs: [plan, sign-macos, sign-windows, publish-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-cli.sh "$RUNNER_TEMP/in/build-archives" "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-windows"
|
||||
env: &cloudflare
|
||||
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
|
||||
publish-desktop:
|
||||
needs: [plan, sign-macos, sign-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{sign-macos,sign-desktop-windows-installer,build-desktop-linux-*}"
|
||||
digests: sign-macos=${{ needs.sign-macos.outputs.digest }} sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Publish
|
||||
run: |
|
||||
bash .github/release/publish-desktop.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-desktop-windows-installer" \
|
||||
"$RUNNER_TEMP/in/build-desktop-linux-x64" "$RUNNER_TEMP/in/build-desktop-linux-arm64"
|
||||
env: *cloudflare
|
||||
|
||||
publish-docker:
|
||||
needs: [plan, build-docker]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: build-docker
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-docker.sh "$RUNNER_TEMP/in/build-docker"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
publish-homebrew:
|
||||
needs: [plan, sign-macos, sign-windows, publish-cli]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- id: token
|
||||
name: Create token
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
|
||||
with:
|
||||
app-id: ${{ vars.OPENCODE_APP_ID }}
|
||||
private-key: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||
owner: anomalyco
|
||||
repositories: homebrew-tap
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-homebrew.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/build-archives"
|
||||
env:
|
||||
HOMEBREW_TOKEN: ${{ steps.token.outputs.token }}
|
||||
|
||||
# The AUR package installs the published npm tarballs, so it follows the npm publish.
|
||||
publish-aur:
|
||||
needs: [plan, sign-macos, sign-windows, publish-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-aur.sh "$RUNNER_TEMP/in/build-npm"
|
||||
env:
|
||||
AUR_KEY: ${{ secrets.AUR_KEY }}
|
||||
|
||||
# WinGet manifests as data. Submission to microsoft/winget-pkgs stays paused until the packages are accepted.
|
||||
publish-winget:
|
||||
needs: [plan, sign-windows, sign-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{sign-windows,sign-desktop-windows-installer}"
|
||||
digests: sign-windows=${{ needs.sign-windows.outputs.digest }} sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Render
|
||||
run: bash .github/release/render-winget.sh "$RUNNER_TEMP/in/sign-windows" "$RUNNER_TEMP/in/sign-desktop-windows-installer" "$RUNNER_TEMP/out"
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: publish-winget
|
||||
path: ${{ runner.temp }}/out
|
||||
|
||||
publish-github-release:
|
||||
needs: [plan, sign-macos, sign-windows, sign-desktop-windows-installer, publish-cli, publish-desktop]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-archives,build-desktop-linux-*,sign-macos,sign-windows,sign-desktop-windows-installer}"
|
||||
digests: >-
|
||||
sign-macos=${{ needs.sign-macos.outputs.digest }} sign-windows=${{ needs.sign-windows.outputs.digest }}
|
||||
sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-github-release.sh "$RUNNER_TEMP"/in/*
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
|
||||
|
||||
# Brings the release commit back to dev. Pushing to dev is blocked by rulesets, so it opens a PR.
|
||||
publish-version-pr:
|
||||
needs: [plan, tag, publish-npm, publish-cli, publish-desktop, publish-github-release]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.channel == 'latest' }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-version-pr.sh "$SHA"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
SHA: ${{ needs.tag.outputs.sha }}
|
||||
@@ -0,0 +1,740 @@
|
||||
name: release
|
||||
run-name: "${{ format('release {0}{1}', inputs.bump, inputs.version) }}"
|
||||
|
||||
# Builds are separated from signing and publishing.
|
||||
# - build-* jobs run repository code (`bun run build`, `bun run pack`) with no environment, secrets or id-token.
|
||||
# - sign-* and publish-* jobs run in the release environment, check out only .github/release/, and run those
|
||||
# scripts on verified artifacts, which they treat as data. They never execute repository code.
|
||||
# - plan decides version, channel and npm dist-tag from the event, inputs and ref; only a dispatch with a bump or
|
||||
# version on dev reaches latest.
|
||||
# .github/release/ and this file are the security boundary for releases.
|
||||
|
||||
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 GitHub release (optional)"
|
||||
required: false
|
||||
type: string
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-${{ (inputs.bump || inputs.version) && 'release' || 'build' }}
|
||||
# Beta ships only the newest commit to the team. A cancelled beta run can leave unreferenced files in R2, but only
|
||||
# publish-desktop records a release, in one request.
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref_name == 'beta' }}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
if: github.repository == 'anomalyco/opencode'
|
||||
runs-on: ubuntu-24.04
|
||||
permissions: {}
|
||||
outputs:
|
||||
version: ${{ steps.plan.outputs.version }}
|
||||
channel: ${{ steps.plan.outputs.channel }}
|
||||
npm_tag: ${{ steps.plan.outputs.npm_tag }}
|
||||
dry_run: ${{ steps.plan.outputs.dry_run }}
|
||||
cli: ${{ steps.plan.outputs.cli }}
|
||||
desktop: ${{ steps.plan.outputs.desktop }}
|
||||
node: ${{ steps.plan.outputs.node }}
|
||||
release: ${{ steps.plan.outputs.release }}
|
||||
steps:
|
||||
- &checkout-release
|
||||
name: Check out release scripts
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
with:
|
||||
ref: ${{ github.sha }}
|
||||
sparse-checkout: /.github/release/
|
||||
sparse-checkout-cone-mode: false
|
||||
persist-credentials: false
|
||||
- id: plan
|
||||
name: Plan
|
||||
run: bash .github/release/plan-release.sh
|
||||
env:
|
||||
INPUT_BUMP: ${{ inputs.bump }}
|
||||
INPUT_VERSION: ${{ inputs.version }}
|
||||
|
||||
# A versioned release builds from a commit with its versions and changelog on the dispatched dev commit,
|
||||
# tagged v<version>. Runs git only.
|
||||
tag:
|
||||
needs: plan
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
env: &env
|
||||
OPENCODE_VERSION: ${{ needs.plan.outputs.version }}
|
||||
OPENCODE_CHANNEL: ${{ needs.plan.outputs.channel }}
|
||||
OPENCODE_NPM_TAG: ${{ needs.plan.outputs.npm_tag }}
|
||||
OPENCODE_DRY_RUN: ${{ needs.plan.outputs.dry_run }}
|
||||
outputs:
|
||||
sha: ${{ steps.tag.outputs.sha || github.sha }}
|
||||
steps:
|
||||
- name: Check out
|
||||
if: needs.plan.outputs.channel == 'latest'
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
- id: tag
|
||||
name: Tag
|
||||
if: needs.plan.outputs.channel == 'latest'
|
||||
run: bash .github/release/tag-release.sh
|
||||
env:
|
||||
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
|
||||
|
||||
# ---- Build: repository code; no environment, secrets or id-token --------------------------------------------
|
||||
|
||||
# Fetches the models.dev catalog once per run, so every CLI bundles the same copy.
|
||||
models-catalog:
|
||||
needs: [plan, tag]
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env: *env
|
||||
steps:
|
||||
- &checkout
|
||||
name: Check out
|
||||
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||
with:
|
||||
ref: ${{ needs.tag.outputs.sha }}
|
||||
persist-credentials: false
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Fetch
|
||||
run: bun packages/core/script/update-models-snapshot.ts .cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog/api.json
|
||||
if-no-files-found: error
|
||||
|
||||
build-cli:
|
||||
needs: [plan, tag, models-catalog]
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
bun-version: 1.4.4
|
||||
- &download-models-catalog
|
||||
name: Download models catalog
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: models-catalog
|
||||
path: .cache/models-catalog
|
||||
- name: Build
|
||||
working-directory: packages/cli
|
||||
run: bun run build && rm -rf dist/.bun
|
||||
env:
|
||||
BUN_COMPILE_RELEASE: bun-v1.4.4
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
OPENCODE_RELEASE_NOTES: ${{ needs.plan.outputs.channel == 'latest' && inputs.release_notes || '' }}
|
||||
GH_TOKEN: ${{ github.token }} # read-only; raises the rate limit for Bun release downloads
|
||||
- name: Verify bundled models catalog
|
||||
run: bun packages/cli/script/catalog-smoke.ts packages/cli/dist/cli-linux-x64/bin/opencode
|
||||
env:
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-cli
|
||||
path: packages/cli/dist
|
||||
|
||||
build-node:
|
||||
needs: [plan, tag, models-catalog]
|
||||
if: needs.plan.outputs.node == 'true'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { 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 }
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "26.4.0"
|
||||
- *download-models-catalog
|
||||
- name: Build
|
||||
working-directory: packages/cli
|
||||
run: bun run build:node
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Test
|
||||
if: matrix.target != 'windows-arm64'
|
||||
working-directory: packages/cli
|
||||
run: bun run script/service-smoke.ts --node
|
||||
- name: Verify bundled models catalog
|
||||
if: matrix.target != 'windows-arm64'
|
||||
run: bun packages/cli/script/catalog-smoke.ts "packages/cli/dist/node/cli-node-$OPENCODE_TARGET/bin/opencode2-node$EXE"
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
EXE: ${{ startsWith(matrix.target, 'windows') && '.exe' || '' }}
|
||||
OPENCODE_MODELS_SNAPSHOT: ${{ github.workspace }}/.cache/models-catalog/api.json
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-node-${{ matrix.target }}
|
||||
path: packages/cli/dist/node
|
||||
|
||||
# `bun run pack` packs every npm package into dist/npm and the Linux and Node CLI archives into dist/archives.
|
||||
# The macOS and Windows CLI packages and archives are re-packed after signing.
|
||||
build-npm:
|
||||
needs: [plan, tag, build-cli, build-node]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- &download-cli
|
||||
name: Download
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-cli
|
||||
path: packages/cli/dist
|
||||
- name: Download Node CLI
|
||||
if: needs.plan.outputs.node == 'true'
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
pattern: build-node-*
|
||||
path: packages/cli/dist/node
|
||||
merge-multiple: true
|
||||
- name: Pack
|
||||
run: rm packages/cli/dist/SHA256SUMS && bun run pack
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-npm
|
||||
path: dist/npm
|
||||
- name: Upload archives
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-archives
|
||||
path: dist/archives
|
||||
|
||||
build-docker:
|
||||
needs: [plan, tag, build-cli]
|
||||
if: needs.plan.outputs.release == 'true'
|
||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- *download-cli
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||
- name: Set up Buildx
|
||||
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
- name: Pack
|
||||
working-directory: packages/cli
|
||||
run: bun run pack:docker
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-docker
|
||||
path: dist/docker
|
||||
|
||||
# macOS and Windows pack an unsigned app; Linux packs the final AppImage, deb and rpm.
|
||||
# Beta packages macOS x64 on Apple Silicon and Windows arm64 on Blacksmith for speed. electron-builder's afterPack
|
||||
# rejects a bundle whose CLI or node-pty does not match the target CPU.
|
||||
build-desktop:
|
||||
needs: [plan, tag, build-cli]
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read # beta builds read who made each change and what it does for "What's new in beta"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: darwin-x64
|
||||
host: ${{ github.ref_name == 'beta' && 'macos-26' || 'macos-26-intel' }}
|
||||
install: ${{ github.ref_name == 'beta' && '--os=darwin --cpu=*' || '--os=darwin --cpu=x64' }}
|
||||
- { target: darwin-arm64, host: macos-26, install: --os=darwin --cpu=arm64 }
|
||||
# github-hosted: blacksmith lacks the ARM64 MSVC cross-compilation toolchain
|
||||
- target: windows-arm64
|
||||
host: ${{ github.ref_name == 'beta' && 'blacksmith-4vcpu-windows-2025' || 'windows-2025' }}
|
||||
install: --cpu=*
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
- { target: linux-x64, host: blacksmith-4vcpu-ubuntu-2404 }
|
||||
- { target: linux-arm64, host: blacksmith-4vcpu-ubuntu-2404-arm }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- *download-cli
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
install-flags: ${{ matrix.install }}
|
||||
- name: Set up rpm
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends rpm
|
||||
# The beta build embeds the subjects of its newest commits for "What's new in beta"
|
||||
# (packages/desktop/script/beta-notes.ts). Commits without file contents are enough.
|
||||
- name: Fetch beta history
|
||||
if: needs.plan.outputs.channel == 'beta'
|
||||
run: git fetch --no-tags --filter=blob:none --depth=300 origin "$SHA"
|
||||
env:
|
||||
SHA: ${{ needs.tag.outputs.sha }}
|
||||
# Beta trades larger packages for faster packaging. fpm sets XZ_OPT for the deb and rpm level, but xz still
|
||||
# reads XZ_DEFAULTS, so it uses every CPU.
|
||||
- name: Beta packaging settings
|
||||
if: needs.plan.outputs.channel == 'beta' && runner.os == 'Linux'
|
||||
run: echo "XZ_DEFAULTS=-T0" >> "$GITHUB_ENV"
|
||||
- name: Build
|
||||
working-directory: packages/desktop
|
||||
run: bun run build
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
NODE_OPTIONS: --max-old-space-size=4096
|
||||
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
|
||||
VITE_SENTRY_ENVIRONMENT: ${{ needs.plan.outputs.channel == 'beta' && 'beta' || 'production' }}
|
||||
VITE_SENTRY_RELEASE: desktop@${{ needs.plan.outputs.version }}
|
||||
GITHUB_TOKEN: ${{ github.token }} # read-only; beta notes read pull request authors and descriptions
|
||||
- name: Pack
|
||||
working-directory: packages/desktop
|
||||
timeout-minutes: 60
|
||||
run: bun run pack
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-desktop-${{ matrix.target }}
|
||||
path: dist/desktop
|
||||
|
||||
# Packs the NSIS installer around the signed app. This runs repository config, so it is a build job; the
|
||||
# installer is signed next.
|
||||
build-desktop-windows-installer:
|
||||
needs: [plan, tag, sign-windows]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: windows-arm64
|
||||
host: ${{ github.ref_name == 'beta' && 'blacksmith-4vcpu-windows-2025' || 'windows-2025' }}
|
||||
install: --cpu=*
|
||||
- { target: windows-x64, host: blacksmith-4vcpu-windows-2025 }
|
||||
runs-on: ${{ matrix.host }}
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout
|
||||
- name: Set up Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
install-flags: ${{ matrix.install }}
|
||||
- name: Download
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: sign-desktop-${{ matrix.target }}
|
||||
path: ${{ runner.temp }}/app
|
||||
- name: Pack
|
||||
working-directory: packages/desktop
|
||||
timeout-minutes: 30
|
||||
run: bun run pack
|
||||
env:
|
||||
OPENCODE_TARGET: ${{ matrix.target }}
|
||||
OPENCODE_DESKTOP_APP: ${{ runner.temp }}/app/app
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: build-desktop-windows-installer-${{ matrix.target }}
|
||||
path: dist/desktop
|
||||
|
||||
# ---- Sign: release environment; only .github/release/ is checked out ----------------------------------------
|
||||
# Pull requests run sign and publish jobs without an environment, so steps that need a secret skip or dry-run.
|
||||
|
||||
# Signs the macOS CLI; signs the desktop apps inside-out, notarizes them in one submission, staples them, and
|
||||
# only then builds the zip, dmg and .app.tar.gz from the stapled apps.
|
||||
sign-macos:
|
||||
needs: [plan, build-npm, build-desktop]
|
||||
if: ${{ !cancelled() && !failure() && (needs.plan.outputs.cli == 'true' || needs.plan.outputs.desktop == 'true') }}
|
||||
runs-on: macos-26
|
||||
timeout-minutes: 90
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-desktop-darwin-*}"
|
||||
- name: Import certificate
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
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 }}
|
||||
- name: Sign CLI
|
||||
if: needs.plan.outputs.cli == 'true'
|
||||
run: bash .github/release/sign-cli-macos.sh "$RUNNER_TEMP/in/build-npm" "$RUNNER_TEMP/out"
|
||||
- name: Sign desktop
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
run: |
|
||||
bash .github/release/sign-desktop-macos.sh "$RUNNER_TEMP/out" \
|
||||
"$RUNNER_TEMP"/in/build-desktop-darwin-*/opencode-desktop-mac-*.app.tar
|
||||
env:
|
||||
APPLE_API_KEY_CONTENT: ${{ secrets.APPLE_API_KEY_PATH }}
|
||||
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
|
||||
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
|
||||
- id: upload
|
||||
name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-macos
|
||||
path: ${{ runner.temp }}/out
|
||||
|
||||
# Signs the Windows CLI and every executable and native module of the unpacked desktop apps.
|
||||
sign-windows:
|
||||
needs: [plan, build-npm, build-desktop]
|
||||
if: ${{ !cancelled() && !failure() && (needs.plan.outputs.cli == 'true' || needs.plan.outputs.desktop == 'true') }}
|
||||
runs-on: windows-2025
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-desktop-windows-*}"
|
||||
- name: Unpack
|
||||
run: bash .github/release/unpack-windows.sh "$RUNNER_TEMP/in" "$RUNNER_TEMP/work"
|
||||
- &azure-login
|
||||
name: Log in to Azure
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
- &azure-sign
|
||||
name: Sign
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: azure/artifact-signing-action@b443cf8ea4124818d2ea9f043cba29fc3ec47b16 # v1.2.0
|
||||
with:
|
||||
endpoint: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
||||
signing-account-name: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
||||
certificate-profile-name: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
||||
files-folder: ${{ runner.temp }}\work
|
||||
files-folder-filter: exe,node
|
||||
files-folder-recurse: true
|
||||
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: Repack
|
||||
run: bash .github/release/repack-windows.sh "$RUNNER_TEMP/work" "$RUNNER_TEMP/out"
|
||||
- id: upload
|
||||
name: Upload
|
||||
if: needs.plan.outputs.cli == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-windows
|
||||
path: ${{ runner.temp }}/out
|
||||
- name: Upload arm64 app
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-arm64
|
||||
path: ${{ runner.temp }}/work/desktop-windows-arm64
|
||||
- name: Upload x64 app
|
||||
if: needs.plan.outputs.desktop == 'true'
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-x64
|
||||
path: ${{ runner.temp }}/work/desktop-windows-x64
|
||||
|
||||
sign-desktop-windows-installer:
|
||||
needs: [plan, build-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
runs-on: windows-2025
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
outputs:
|
||||
digest: ${{ steps.upload.outputs.digest }}
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: build-desktop-windows-installer-*
|
||||
- name: Unpack
|
||||
run: mkdir -p "$RUNNER_TEMP/work" && cp "$RUNNER_TEMP"/in/build-desktop-windows-installer-*/*.exe "$RUNNER_TEMP/work/"
|
||||
- *azure-login
|
||||
- *azure-sign
|
||||
- name: Repack
|
||||
run: bash .github/release/repack-windows.sh "$RUNNER_TEMP/work" "$RUNNER_TEMP/out"
|
||||
- id: upload
|
||||
name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: sign-desktop-windows-installer
|
||||
path: ${{ runner.temp }}/work
|
||||
|
||||
# ---- Publish: release environment; only .github/release/ is checked out -------------------------------------
|
||||
# Destinations, names and channels come from plan and the scripts, never from artifacts.
|
||||
|
||||
# Build provenance for the npm tarballs and Linux archives. No secrets; id-token only for Sigstore.
|
||||
publish-attestations:
|
||||
needs: [plan, build-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' && needs.plan.outputs.dry_run != 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: write
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-archives}"
|
||||
- name: Sign
|
||||
uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
|
||||
with:
|
||||
subject-path: |
|
||||
${{ runner.temp }}/in/build-npm/*.tgz
|
||||
${{ runner.temp }}/in/build-archives/opencode*
|
||||
|
||||
publish-npm:
|
||||
needs: [plan, sign-macos, sign-windows, publish-attestations]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
attestations: read
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||
with:
|
||||
node-version: "24.11.0"
|
||||
- &download-signed-cli
|
||||
name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-npm,build-archives,sign-macos,sign-windows}"
|
||||
digests: sign-macos=${{ needs.sign-macos.outputs.digest }} sign-windows=${{ needs.sign-windows.outputs.digest }}
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-npm.sh "$RUNNER_TEMP/in/build-npm" "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-windows"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
publish-cli:
|
||||
needs: [plan, sign-macos, sign-windows, publish-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.cli == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-cli.sh "$RUNNER_TEMP/in/build-archives" "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-windows"
|
||||
env: &cloudflare
|
||||
CLOUDFLARE_ACCOUNT_ID: 15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
|
||||
publish-desktop:
|
||||
needs: [plan, sign-macos, sign-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.desktop == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{sign-macos,sign-desktop-windows-installer,build-desktop-linux-*}"
|
||||
digests: sign-macos=${{ needs.sign-macos.outputs.digest }} sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Publish
|
||||
run: |
|
||||
bash .github/release/publish-desktop.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-desktop-windows-installer" \
|
||||
"$RUNNER_TEMP/in/build-desktop-linux-x64" "$RUNNER_TEMP/in/build-desktop-linux-arm64"
|
||||
env: *cloudflare
|
||||
|
||||
publish-docker:
|
||||
needs: [plan, build-docker]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: build-docker
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-docker.sh "$RUNNER_TEMP/in/build-docker"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
publish-homebrew:
|
||||
needs: [plan, sign-macos, sign-windows, publish-cli]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- id: token
|
||||
name: Create token
|
||||
if: needs.plan.outputs.dry_run != 'true'
|
||||
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
|
||||
with:
|
||||
app-id: ${{ vars.OPENCODE_APP_ID }}
|
||||
private-key: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||
owner: anomalyco
|
||||
repositories: homebrew-tap
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-homebrew.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/build-archives"
|
||||
env:
|
||||
HOMEBREW_TOKEN: ${{ steps.token.outputs.token }}
|
||||
|
||||
# The AUR package installs the published npm tarballs, so it follows the npm publish.
|
||||
publish-aur:
|
||||
needs: [plan, sign-macos, sign-windows, publish-npm]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- *download-signed-cli
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-aur.sh "$RUNNER_TEMP/in/build-npm"
|
||||
env:
|
||||
AUR_KEY: ${{ secrets.AUR_KEY }}
|
||||
|
||||
# WinGet manifests as data. Submission to microsoft/winget-pkgs stays paused until the packages are accepted.
|
||||
publish-winget:
|
||||
needs: [plan, sign-windows, sign-desktop-windows-installer]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{sign-windows,sign-desktop-windows-installer}"
|
||||
digests: sign-windows=${{ needs.sign-windows.outputs.digest }} sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Render
|
||||
run: bash .github/release/render-winget.sh "$RUNNER_TEMP/in/sign-windows" "$RUNNER_TEMP/in/sign-desktop-windows-installer" "$RUNNER_TEMP/out"
|
||||
- name: Upload
|
||||
uses: ./.github/release/upload
|
||||
with:
|
||||
name: publish-winget
|
||||
path: ${{ runner.temp }}/out
|
||||
|
||||
publish-github-release:
|
||||
needs: [plan, sign-macos, sign-windows, sign-desktop-windows-installer, publish-cli, publish-desktop]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.release == 'true' }}
|
||||
runs-on: ubuntu-24.04
|
||||
environment: ${{ needs.plan.outputs.dry_run != 'true' && 'release' || '' }}
|
||||
permissions:
|
||||
contents: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Download
|
||||
uses: ./.github/release/download
|
||||
with:
|
||||
pattern: "{build-archives,build-desktop-linux-*,sign-macos,sign-windows,sign-desktop-windows-installer}"
|
||||
digests: >-
|
||||
sign-macos=${{ needs.sign-macos.outputs.digest }} sign-windows=${{ needs.sign-windows.outputs.digest }}
|
||||
sign-desktop-windows-installer=${{ needs.sign-desktop-windows-installer.outputs.digest }}
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-github-release.sh "$RUNNER_TEMP"/in/*
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
|
||||
|
||||
# Brings the release commit back to dev. Pushing to dev is blocked by rulesets, so it opens a PR.
|
||||
publish-version-pr:
|
||||
needs: [plan, tag, publish-npm, publish-cli, publish-desktop, publish-github-release]
|
||||
if: ${{ !cancelled() && !failure() && needs.plan.outputs.channel == 'latest' }}
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
env: *env
|
||||
steps:
|
||||
- *checkout-release
|
||||
- name: Publish
|
||||
run: bash .github/release/publish-version-pr.sh "$SHA"
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
SHA: ${{ needs.tag.outputs.sha }}
|
||||
Reference in New Issue
Block a user