isolate release credentials and process daemon publishing

This commit is contained in:
Dax Raad
2026-11-11 20:21:45 -05:00
Unverified
parent b451fe3952
commit a7041d45d6
7 changed files with 164 additions and 128 deletions
+1 -1
View File
@@ -8,4 +8,4 @@ packages/plugin/src/gui/ @Hona
# 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/releasers
/.github/ @thdxr
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -euo pipefail
umask 077
cert="$RUNNER_TEMP/cert.p12"
trap 'rm -f "$cert"' EXIT
keychain_password=$(openssl rand -base64 32)
printf '%s' "$APPLE_SIGNING_CERTIFICATE" | base64 --decode > "$cert"
unset APPLE_SIGNING_CERTIFICATE
security create-keychain -p "$keychain_password" build.keychain
security set-keychain-settings -lut 21600 build.keychain
security unlock-keychain -p "$keychain_password" build.keychain
security import "$cert" -k build.keychain -P "" -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productsign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" build.keychain > /dev/null
security list-keychains -d user -s build.keychain $(security list-keychains -d user | tr -d '"')
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
. "$(dirname "$0")/lib.sh"
version=${GITHUB_REF_NAME#process-daemon-v}
[[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]] || die 'Invalid daemon version'
registry=https://registry.npmjs.org
# Validate every package before the first write. Publish the dispatcher last.
packages=(pty-darwin-{arm64,x64} pty-linux-{arm64,x64}-{gnu,musl} pty-win32-{arm64,x64} pty)
for package in "${packages[@]}"; do
file="$1/opencode-$package-$version.tgz"
tar -xOzf "$file" package/package.json | jq -es --arg name "@opencode/$package" --arg version "$version" '
length == 1 and (.[0] | .name == $name and .version == $version and
((.publishConfig // {}) | del(.access) == {}))' >/dev/null || die "Unexpected manifest for $package"
done
for package in "${packages[@]}"; do
if ! npm view --registry="$registry" "@opencode/$package@$version" version >/dev/null 2>&1; then
npm publish --registry="$registry" --ignore-scripts --access public --provenance "$1/opencode-$package-$version.tgz"
fi
done
+11 -1
View File
@@ -5,6 +5,16 @@
. "$(dirname "$0")/lib.sh"
tag="v$OPENCODE_VERSION"
if ! dry_run; then
umask 077
ssh_dir=$(mktemp -d)
trap 'rm -rf "$ssh_dir"' EXIT
printf '%s\n' "$RELEASE_TAG_KEY" > "$ssh_dir/key"
unset RELEASE_TAG_KEY
echo 'github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzrm0SdG6UOoqKLsabgH5C9okWi0dh2l9GKJl' > "$ssh_dir/known_hosts"
export GIT_SSH_COMMAND="ssh -i $ssh_dir/key -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=$ssh_dir/known_hosts"
git remote set-url origin git@github.com:anomalyco/opencode.git
fi
# @opencode/pty is versioned separately, by process-daemon-v<version> tags.
git ls-files -z -- '*package.json' bun.lock ':!packages/process-daemon/**' | xargs -0 sed -i -E "s/\"version\": \"[^\"]+\"/\"version\": \"$OPENCODE_VERSION\"/g"
@@ -37,5 +47,5 @@ if [ -n "$existing" ]; then
echo "sha=$existing" >> "$GITHUB_OUTPUT"
exit 0
fi
git push -q origin "HEAD:refs/tags/$tag"
if ! dry_run; then git push -q origin "HEAD:refs/tags/$tag"; fi
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Fetch only this command's named secrets; keep credentials out of its environment.
. "$(dirname "$0")/lib.sh"
set +x
while [[ $# -gt 0 && $1 != -- ]]; do
name=${1%%=*} id=${1#*=}
[[ $name =~ ^[A-Z][A-Z0-9_]*$ && $id != "$1" && -n $id ]] || die 'Expected NAME=secret-id'
if ! dry_run; then
value=$(aws secretsmanager get-secret-value --region us-east-1 --secret-id "$id" --query SecretString --output text)
[[ -n $value && $value != None ]] || die "Empty secret: $id"
while IFS= read -r line; do
[[ -z $line ]] || printf '::add-mask::%s\n' "${line//%/%25}"
done <<< "$value"
export "$name=$value"
fi
shift
done
[[ ${1:-} == -- && $# -gt 1 ]] || die 'Expected -- command'
shift
unset AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN value
exec "$@"
+54 -25
View File
@@ -246,13 +246,11 @@ jobs:
path: packages/process-daemon/dist/*.tar.gz
if-no-files-found: error
release:
package:
needs: [checks, build, build-windows]
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
attestations: write
outputs:
digest: ${{ steps.upload.outputs.digest }}
env:
PROTOCOL_VERSION: ${{ needs.checks.outputs.protocol }}
steps:
@@ -261,8 +259,6 @@ jobs:
with:
node-version: "24"
registry-url: https://registry.npmjs.org
- name: Install npm with trusted publishing support
run: npm install --global npm@^11.5.1
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: packages/process-daemon/dist
@@ -297,35 +293,68 @@ jobs:
npm pack --pack-destination "$temporary" dist/npm/opencode-pty-linux-x64-gnu dist/npm/opencode-pty >/dev/null
npm install --prefix "$temporary" --ignore-scripts --no-package-lock --no-audit --no-fund "$temporary"/*.tgz
test "$("$temporary/node_modules/.bin/opencode-pty" --version)" = "opencode-pty $(node -p 'require("./npm/package.json").version') (protocol $PROTOCOL_VERSION)"
- uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
if: startsWith(github.ref, 'refs/tags/process-daemon-v')
- name: Stage release files
run: |
mkdir -p "$RUNNER_TEMP/bundle/github" "$RUNNER_TEMP/bundle/npm"
cp dist/*.tar.gz dist/release-manifest.json dist/SHA256SUMS "$RUNNER_TEMP/bundle/github/"
for package in dist/npm/*; do
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/bundle/npm" "$(realpath "$package")"
done
# The upload action owns the outer SHA256SUMS; include the release checksums in it.
mv "$RUNNER_TEMP/bundle/github/SHA256SUMS" "$RUNNER_TEMP/bundle/github/checksums.txt"
- id: upload
uses: ./.github/release/upload
with:
subject-checksums: packages/process-daemon/dist/SHA256SUMS
name: process-daemon-bundle
path: ${{ runner.temp }}/bundle
release:
needs: [checks, package]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/process-daemon-v')
runs-on: ubuntu-24.04
environment: process-daemon-release
permissions:
contents: write
id-token: write
attestations: write
defaults:
run:
working-directory: .
env:
PROTOCOL_VERSION: ${{ needs.checks.outputs.protocol }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
sparse-checkout: /.github/release/
sparse-checkout-cone-mode: false
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0; caching opt-in
with:
node-version: '24.11.0'
- uses: ./.github/release/download
with:
pattern: process-daemon-bundle
digests: process-daemon-bundle=${{ needs.package.outputs.digest }}
require-digests: 'true'
- uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
with:
subject-path: |
${{ runner.temp }}/in/process-daemon-bundle/github/*.tar.gz
${{ runner.temp }}/in/process-daemon-bundle/github/release-manifest.json
# The monorepo's Latest release drives OpenCode's own update paths, so this release must never become
# Latest. It is drafted first because immutable releases lock assets once published.
- name: Publish release
if: startsWith(github.ref, 'refs/tags/process-daemon-v')
env:
GH_TOKEN: ${{ github.token }}
run: |
cd "$RUNNER_TEMP/in/process-daemon-bundle/github"
mv checksums.txt SHA256SUMS
version="${GITHUB_REF_NAME#process-daemon-v}"
gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 ||
gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft --verify-tag --latest=false \
--title "process-daemon v$version" \
--notes "opencode-pty $version (protocol $PROTOCOL_VERSION) from packages/process-daemon, published to npm as @opencode/pty@$version."
gh release upload "$GITHUB_REF_NAME" dist/*.tar.gz dist/SHA256SUMS dist/release-manifest.json --clobber --repo "$GITHUB_REPOSITORY"
gh release upload "$GITHUB_REF_NAME" ./*.tar.gz SHA256SUMS release-manifest.json --clobber --repo "$GITHUB_REPOSITORY"
gh release edit "$GITHUB_REF_NAME" --draft=false --latest=false --repo "$GITHUB_REPOSITORY"
- name: Publish npm packages
if: startsWith(github.ref, 'refs/tags/process-daemon-v')
run: |
version="${GITHUB_REF_NAME#process-daemon-v}"
for package in dist/npm/opencode-pty-*; do
name="$(node -p 'require(process.argv[1]).name' "$(realpath "$package/package.json")")"
if ! npm view "$name@$version" version >/dev/null 2>&1; then
npm publish "$package" --access public --provenance
fi
done
name="@opencode/pty"
if ! npm view "$name@$version" version >/dev/null 2>&1; then
npm publish dist/npm/opencode-pty --access public --provenance
fi
run: bash .github/release/publish-process-daemon.sh "$RUNNER_TEMP/in/process-daemon-bundle/npm"
+44 -101
View File
@@ -113,33 +113,31 @@ jobs:
outputs:
sha: ${{ steps.tag.outputs.sha || github.sha }}
steps:
# The tag is pushable only with the release deploy key, so without the release environment there is nothing
# to fetch and the checkout below falls back to the workflow token.
- name: Configure AWS credentials
# Fetch the deploy key only for the tag command; checkout uses its read-only token.
- id: aws
name: Configure AWS credentials
if: needs.plan.outputs.channel == 'latest' && needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
with: &release-role
output-env-credentials: false
output-credentials: true
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Read release tag key
if: needs.plan.outputs.channel == 'latest' && needs.plan.outputs.dry_run != 'true'
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
with:
secret-ids: RELEASE_TAG_KEY,opencode/release/RELEASE_TAG_KEY
parse-json-secrets: false
- name: Check out
if: needs.plan.outputs.channel == 'latest'
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
ssh-key: ${{ env.RELEASE_TAG_KEY }}
persist-credentials: false
- id: tag
name: Tag
if: needs.plan.outputs.channel == 'latest'
run: bash .github/release/tag-release.sh
run: bash .github/release/with-secrets.sh RELEASE_TAG_KEY=opencode/release/RELEASE_TAG_KEY -- bash .github/release/tag-release.sh
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
OPENCODE_RELEASE_NOTES: ${{ inputs.release_notes }}
# ---- Build: repository code; no environment, secrets or id-token --------------------------------------------
@@ -433,45 +431,33 @@ jobs:
uses: ./.github/release/download
with:
pattern: "{build-npm,build-desktop-darwin-*}"
- name: Configure AWS credentials
- &configure-release-role
id: aws
name: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Read signing secrets
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
with:
secret-ids: |
APPLE_SIGNING_CERTIFICATE,shared/APPLE_SIGNING_CERTIFICATE
APPLE_NOTARY_KEY,shared/APPLE_NOTARY_KEY
parse-json-secrets: false
with: *release-role
# The certificate has no password, which apple-actions/import-codesign-certs rejects. The sign scripts look up
# the identity in build.keychain, and codesign finds the key through the user search list.
- name: Import certificate
if: needs.plan.outputs.dry_run != 'true'
run: |
cert="$RUNNER_TEMP/cert.p12"
keychain_password=$(openssl rand -base64 32)
printf '%s' "$APPLE_SIGNING_CERTIFICATE" | base64 --decode > "$cert"
security create-keychain -p "$keychain_password" build.keychain
security set-keychain-settings -lut 21600 build.keychain
security unlock-keychain -p "$keychain_password" build.keychain
security import "$cert" -k build.keychain -P "" -T /usr/bin/codesign -T /usr/bin/security -T /usr/bin/productsign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" build.keychain > /dev/null
security list-keychains -d user -s build.keychain $(security list-keychains -d user | tr -d '"')
rm -f "$cert"
env: &aws-step
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
run: bash .github/release/with-secrets.sh APPLE_SIGNING_CERTIFICATE=shared/APPLE_SIGNING_CERTIFICATE -- bash .github/release/import-certificate.sh
- 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" \
bash .github/release/with-secrets.sh APPLE_NOTARY_KEY=shared/APPLE_NOTARY_KEY -- bash .github/release/sign-desktop-macos.sh "$RUNNER_TEMP/out" \
"$RUNNER_TEMP"/in/build-desktop-darwin-*/opencode-desktop-mac-*.app.tar
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
APPLE_NOTARY_KEY_ID: ${{ vars.APPLE_NOTARY_KEY_ID }}
APPLE_NOTARY_ISSUER_ID: ${{ vars.APPLE_NOTARY_ISSUER_ID }}
- id: upload
@@ -519,6 +505,7 @@ jobs:
if: needs.plan.outputs.dry_run != 'true'
uses: azure/artifact-signing-action@b443cf8ea4124818d2ea9f043cba29fc3ec47b16 # v1.2.0
with:
cache-dependencies: false
endpoint: ${{ vars.AZURE_TRUSTED_SIGNING_ENDPOINT }}
signing-account-name: ${{ vars.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
certificate-profile-name: ${{ vars.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
@@ -651,18 +638,16 @@ jobs:
steps:
- *checkout-release
- *download-signed-cli
- name: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Cloudflare token
- *configure-release-role
- &cloudflare-token
name: Cloudflare token
id: cloudflare-token
if: needs.plan.outputs.dry_run != 'true'
run: bash .github/release/cloudflare-token.sh
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
- name: Publish
run: bash .github/release/publish-cli.sh "$RUNNER_TEMP/in/build-archives" "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-windows"
@@ -686,19 +671,8 @@ jobs:
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: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Cloudflare token
id: cloudflare-token
if: needs.plan.outputs.dry_run != 'true'
run: bash .github/release/cloudflare-token.sh
env:
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
- *configure-release-role
- *cloudflare-token
- name: Publish
run: |
bash .github/release/publish-desktop.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/sign-desktop-windows-installer" \
@@ -737,21 +711,10 @@ jobs:
steps:
- *checkout-release
- *download-signed-cli
- name: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Read publish secrets
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
with:
secret-ids: HOMEBREW_TAP_DEPLOY_KEY,shared/HOMEBREW_TAP_DEPLOY_KEY
parse-json-secrets: false
- *configure-release-role
- name: Publish
run: bash .github/release/publish-homebrew.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/build-archives"
env: *aws-step
run: bash .github/release/with-secrets.sh HOMEBREW_TAP_DEPLOY_KEY=shared/HOMEBREW_TAP_DEPLOY_KEY -- bash .github/release/publish-homebrew.sh "$RUNNER_TEMP/in/sign-macos" "$RUNNER_TEMP/in/build-archives"
# The AUR package installs the published npm tarballs, so it follows the npm publish.
publish-aur:
@@ -766,21 +729,10 @@ jobs:
steps:
- *checkout-release
- *download-signed-cli
- name: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Read publish secrets
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
with:
secret-ids: AUR_KEY,shared/AUR_SSH_KEY
parse-json-secrets: false
- *configure-release-role
- name: Publish
run: bash .github/release/publish-aur.sh "$RUNNER_TEMP/in/build-npm"
env: *aws-step
run: bash .github/release/with-secrets.sh AUR_KEY=shared/AUR_SSH_KEY -- bash .github/release/publish-aur.sh "$RUNNER_TEMP/in/build-npm"
# WinGet manifests as data. Submission to microsoft/winget-pkgs stays paused until the packages are accepted.
publish-winget:
@@ -838,22 +790,13 @@ jobs:
env: *env
steps:
- *checkout-release
- name: Configure AWS credentials
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/configure-aws-credentials@e1253824e5c10ff9df46874f81ed3ec929e19cfd # v6.3.0
with:
role-to-assume: arn:aws:iam::604439173067:role/github/opencode-release
role-session-name: opencode-${{ github.run_id }}
aws-region: us-east-1
- name: Read publish secrets
if: needs.plan.outputs.dry_run != 'true'
uses: aws-actions/aws-secretsmanager-get-secrets@2297f9a879480a9e3af9b293ed15c70caf8e1c88 # v3.0.2
with:
secret-ids: DISCORD_WEBHOOK,opencode/release/DISCORD_WEBHOOK
parse-json-secrets: false
- *configure-release-role
- name: Publish
run: bash .github/release/publish-discord.sh
run: bash .github/release/with-secrets.sh DISCORD_WEBHOOK=opencode/release/DISCORD_WEBHOOK -- bash .github/release/publish-discord.sh
env:
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
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.