Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions .agents/skills/release-update/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ existing production binary and no store binary or compliance update is needed.
- `bun eas:prod:android`
- `bun eas:prod:ios`
- `bun eas:preview:android` for an internal-distribution check first
- or the Codemagic `ios-production` / `android-production` workflows. Push a
`v<version>` tag on the merged main commit (`git tag v1.6.0 && git push
origin v1.6.0`); the tag must match `package.json`. They load the `production` EAS environment,
- or the Codemagic `ios-production` / `android-production` workflows: run
the GitHub Actions `Release` workflow with kind `store` (`gh workflow run
Release -f kind=store -f message="<notes>"`). After CI passed on main it
tags `v<package.json version>` and creates a GitHub Release; pushing that
tag by hand does the same when Actions cannot run. They load the `production` EAS environment,
sign from the secure `bookoo_production` group, fail unless the bundle
targets the production Convex host (and, on Android, unless the upload key
signed it), then upload to TestFlight and a Play internal draft. Review
Expand Down Expand Up @@ -109,12 +111,18 @@ existing production binary and no store binary or compliance update is needed.
a useful message explicitly:
- `OTA_CONFIRM_COMPATIBLE=1 OTA_MESSAGE="<notes>" bun ota:release`
- append `:ios` or `:android` to target one platform.
- or from Codemagic: push an annotated `ota-<label>` tag on the tip of main
- or from Codemagic: run the `Release` workflow with kind `ota` (`gh
workflow run Release -f kind=ota -f message="<notes>"`), which tags
`ota-<version>-<n>` on a green main commit; kind `ota-dry` does the whole
run without the upload. Without Actions, push the annotated tag by hand
(`git tag -a ota-1.5.0-1 -m "<notes>" && git push origin ota-1.5.0-1`).
The `ota-production` workflow runs this same script for both platforms with
`OTA_VERIFY=local`; the tag message is the release note and pushing the tag
is the compatibility attestation. `ota-dry-<label>` runs every gate
without publishing.
The `ota-production` workflow runs this same script for both platforms;
on Codemagic it requires the tag to be on main and runs CI's check
commands itself. The tag message is the release note and the tag is the
compatibility attestation.
Every release first runs `expo prebuild --no-install --clean` for its
platform: Patch fingerprints the generated native projects and blocks a
release whose fingerprint differs from earlier ones for that binary.
The guard publishes to the Patch `Production` deployment, bundling with
the `production` EAS environment through `eas env:exec`. Never publish
automatically on every merge: native modules, config plugins, permissions,
Expand All @@ -123,8 +131,8 @@ existing production binary and no store binary or compliance update is needed.
- Sign in once with `bunx @codemagic/patch-cli@0.10.0 login --server-url
https://ota.codemagicpatch.dev`. QA builds read the `Staging` deployment;
test there first with `cmpatch release-react --deployment Staging`.
- add `OTA_DRY_RUN=1` to verify the exact-main and successful-CI gates
without bundling or publishing.
- add `OTA_DRY_RUN=1` to run every gate, the prebuild and the bundle and
fingerprint with `release-react --dry-run`, without uploading.
- when GitHub Actions cannot run, add `OTA_VERIFY=local`: the script
runs CI's `check` commands (`bun lint:all`, `bun typecheck`, `bun run
test`) on that exact clean commit instead of looking up the CI run. Never
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release

# Starts a Codemagic release from GitHub. It only creates a tag on the current
# main commit after that commit's CI passed; Codemagic's webhook does the rest
# (codemagic.yaml):
# store -> tag v<package.json version> + GitHub Release
# -> ios-production and android-production (TestFlight, Play draft)
# ota -> annotated tag ota-<version>-<n> -> ota-production (Codemagic Patch)
# ota-dry -> annotated tag ota-dry-<version>-<n> -> the same OTA run, without
# the upload
# When Actions cannot run, push the same tag by hand; Codemagic treats it alike.

on:
workflow_dispatch:
inputs:
kind:
description: What to release
type: choice
options:
- ota
- ota-dry
- store
required: true
message:
description: Release note (the OTA note and the GitHub Release text)
type: string
required: true

permissions:
actions: read
contents: write

concurrency:
group: release
cancel-in-progress: false

jobs:
tag:
if: ${{ github.repository == 'hyodotdev/BooKoo' && github.ref == 'refs/heads/main' }}
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
fetch-tags: true

- name: Require successful CI for this commit
env:
GH_TOKEN: ${{ github.token }}
run: |
state=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow CI \
--commit "$GITHUB_SHA" --event push --limit 1 \
--json status,conclusion \
--jq 'if length == 1 then "\(.[0].status):\(.[0].conclusion)" else "" end')
if [ "$state" != "completed:success" ]; then
echo "::error::CI for $GITHUB_SHA is '${state:-missing}'; release only a green main commit."
exit 1
fi

- name: Create and push the release tag
env:
KIND: ${{ inputs.kind }}
MESSAGE: ${{ inputs.message }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
version=$(node -p 'require("./package.json").version')
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
case "$KIND" in
store)
tag="v$version"
if git rev-parse -q --verify "refs/tags/$tag" > /dev/null; then
echo "::error::$tag already exists; bump the version in package.json first."
exit 1
fi
;;
ota | ota-dry)
prefix="$KIND-$version-"
last=$(git tag -l "$prefix*" | sed "s/^$prefix//" | grep -E '^[0-9]+$' | sort -n | tail -1 || true)
tag="$prefix$(( ${last:-0} + 1 ))"
;;
*)
echo "::error::Unknown release kind $KIND"
exit 1
;;
esac
git tag -a "$tag" -m "$MESSAGE"
git push origin "$tag"
if [ "$KIND" = store ]; then
gh release create "$tag" --verify-tag --title "$tag" --notes "$MESSAGE"
fi
{
echo "### Tagged \`$tag\` on \`${GITHUB_SHA::7}\`"
echo "Codemagic picks it up: https://codemagic.io/builds"
} >> "$GITHUB_STEP_SUMMARY"
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ Always write commit messages in Angular Conventional Commits format.
- Never enqueue an EAS cloud build. Every EAS native build must use
`eas build --local`, including production and store-candidate builds.
- Store binaries may instead come from the Codemagic `ios-production` and
`android-production` workflows in `codemagic.yaml`, started by pushing a
`v<version>` tag on main (or by hand). They upload to
`android-production` workflows in `codemagic.yaml`, started by the GitHub
Actions `Release` workflow (kind `store`), a hand-pushed `v<version>` tag on
main, or by hand in Codemagic. They upload to
TestFlight and a Play internal draft only, never submit for review, and
number each build one above the latest store build. The EAS remote counter
then falls behind: raise it with `eas build:version:set` before the next EAS
Expand Down
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ table or function names outside that authority.
- Never enqueue an EAS cloud build. Every EAS native build must use
`eas build --local`, including production and store-candidate builds.
- Store binaries may instead come from the Codemagic `ios-production` and
`android-production` workflows in `codemagic.yaml`, started by pushing a
`v<version>` tag on main (or by hand). They upload to
`android-production` workflows in `codemagic.yaml`, started by the GitHub
Actions `Release` workflow (kind `store`), a hand-pushed `v<version>` tag on
main, or by hand in Codemagic. They upload to
TestFlight and a Play internal draft only, never submit for review, and
number each build one above the latest store build. The EAS remote counter
then falls behind: raise it with `eas build:version:set` before the next EAS
Expand Down
34 changes: 18 additions & 16 deletions codemagic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
# ota-<label> (annotated; its message is the release note) ota-production
# publishes a Codemagic Patch update to the Production
# deployment through scripts/ota-release.zsh.
# ota-dry-<label> runs every OTA gate without publishing.
# Each workflow can also be started by hand. They read every credential from the
# ota-dry-<label> runs every OTA step, prebuild and bundle included, without
# uploading.
# The GitHub Actions `Release` workflow (.github/workflows/release.yml) creates
# these tags after CI passed; pushing the same tag by hand works when Actions
# cannot run. Each workflow can also be started by hand. They read every credential from the
# secure `bookoo_production` group. The GitHub webhook sends push and
# tag-creation events only: Codemagic builds a pull request from the yaml on its
# source branch, so PR events must not reach Codemagic until fork builds are
Expand Down Expand Up @@ -305,29 +308,28 @@ workflows:
- pattern: 'ota-*'
include: true
scripts:
- name: Require the tag to be the tip of main
script: |
set -euo pipefail
git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main
[ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ] \
|| { echo "OTA must publish the current main; ${CM_TAG:-this commit} is not its tip"; exit 1; }
# ota-release.zsh insists on the main branch; a tag build is detached.
git checkout -q -B main
- *install_bun
- *install_dependencies
- name: Check the Patch access
script: |
set -euo pipefail
test -n "${CODEMAGIC_PATCH_TOKEN:-}" \
|| { echo "CODEMAGIC_PATCH_TOKEN is missing from bookoo_production"; exit 1; }
bunx @codemagic/patch-cli@0.10.0 whoami --server-url https://ota.codemagicpatch.dev > /dev/null
echo "Patch login works"
- name: Publish the OTA update
script: |
set -euo pipefail
if [ -n "${CM_TAG:-}" ]; then
message=$(git tag -l --format='%(contents:subject)' "$CM_TAG")
[ "$(git cat-file -t "$CM_TAG")" = tag ] \
|| { echo "Use an annotated tag: its message is the release note"; exit 1; }
message=$(git tag -l --format='%(contents:subject)' "$CM_TAG")
else
message="${OTA_MESSAGE:-}"
fi
case "${CM_TAG:-}" in ota-dry-*) export OTA_DRY_RUN=1 ;; esac
# The tag is the explicit JavaScript/assets-only attestation that the
# script asks for. Actions minutes are not available, so the CI check
# commands run here on the exact commit.
OTA_CONFIRM_COMPATIBLE=1 OTA_VERIFY=local OTA_MESSAGE="$message" \
zsh scripts/ota-release.zsh all
# The tag is the explicit JavaScript/assets-only attestation the
# script asks for. On Codemagic (CM_BUILD_ID) the script requires the
# commit to be on main and runs CI's check commands itself, then
# regenerates the native projects so Patch can fingerprint them.
OTA_CONFIRM_COMPATIBLE=1 OTA_MESSAGE="$message" zsh scripts/ota-release.zsh all
37 changes: 27 additions & 10 deletions docs/ai/WORKFLOWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,16 @@ OTA_MESSAGE="<what changed>" \
bun ota:release
```

Add `OTA_DRY_RUN=1` to verify the branch, clean-tree, exact-main and CI
gates without bundling or publishing an update.
Add `OTA_DRY_RUN=1` to run every gate and the whole build — prebuild, bundle,
fingerprint — through `release-react --dry-run`, without uploading.

Every release regenerates the native projects first
(`expo prebuild --no-install --clean --platform <ios|android>` inside the same
`eas env:exec production` call). Patch fingerprints the generated `ios/` and
`android/` projects and blocks a release whose fingerprint differs from earlier
releases for the same binary version; without a prebuild a clean checkout has no
native project to fingerprint at all. The store build number does not enter the
fingerprint. `--clean` replaces local `ios/` and `android/` folders.

When GitHub Actions cannot run (for example its included minutes are used up),
add `OTA_VERIFY=local`. The script then runs, on that exact clean commit,
Expand All @@ -388,15 +396,24 @@ budget suite and the history secret scan stay CI-only, so the mode is only for
the JavaScript/assets-only updates the compatibility acknowledgement already
requires, and a change under `convex/` must wait for a real CI run.

The same release can run in Codemagic: push an annotated tag named
`ota-<label>` on the tip of main, for example
The same release runs in Codemagic, started from GitHub Actions:

```sh
gh workflow run Release -f kind=ota -f message="Fix the calendar total"
```

The `Release` workflow (`.github/workflows/release.yml`) refuses a main commit
whose CI has not passed, then pushes the annotated tag `ota-<version>-<n>`.
Codemagic's `ota-production` workflow runs this script for both platforms with
the tag message as `OTA_MESSAGE` and the Patch token from the secure
`bookoo_production` group; on Codemagic (`CM_BUILD_ID`) the script requires the
tag to be on main and runs CI's check commands itself. Kind `ota-dry` tags
`ota-dry-<version>-<n>`, which does the same run without the upload; kind
`store` tags `v<version>` with a GitHub Release and starts both store builds.
The tag is the compatibility attestation, so the same rules apply: no native
change, and no `convex/` change without a real CI run. When Actions cannot run,
push the same annotated tag by hand, for example
`git tag -a ota-1.5.0-1 -m "Fix the calendar total" && git push origin ota-1.5.0-1`.
The `ota-production` workflow checks that the tag is the current main, then runs
this script for both platforms with `OTA_VERIFY=local`, the tag message as
`OTA_MESSAGE`, and the Patch token from the secure `bookoo_production` group.
Pushing the tag is the compatibility attestation, so the same rules apply: no
native change, and no `convex/` change without a real CI run. A tag named
`ota-dry-<label>` runs every gate without publishing.

Use `ota:release:ios` or `ota:release:android` only when the compatible change
is intentionally platform-specific. The command bundles with the `production`
Expand Down
84 changes: 56 additions & 28 deletions scripts/ota-release.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,45 @@ script_dir="${0:A:h}"
repo_root="${script_dir:h}"
cd "$repo_root"

current_branch="$(git branch --show-current)"
if [[ "$current_branch" != "main" ]]; then
print -u2 "production OTA must run from main, not $current_branch"
exit 1
fi

if [[ -n "$(git status --porcelain)" ]]; then
print -u2 "production OTA requires a clean worktree"
exit 1
fi

# An explicit refspec: a CI clone of a tag may have no remote-tracking branches,
# and a bare `fetch origin main` then updates only FETCH_HEAD.
git fetch --quiet origin +refs/heads/main:refs/remotes/origin/main
# and a bare `fetch origin main` then updates only FETCH_HEAD. A shallow clone
# also cannot prove ancestry, so it is unshallowed first.
main_ref=+refs/heads/main:refs/remotes/origin/main
if [[ "$(git rev-parse --is-shallow-repository)" == true ]]; then
git fetch --quiet --unshallow origin "$main_ref"
else
git fetch --quiet origin "$main_ref"
fi
local_head="$(git rev-parse HEAD)"
remote_head="$(git rev-parse origin/main)"
if [[ "$local_head" != "$remote_head" ]]; then
print -u2 "production OTA requires HEAD to match origin/main"
exit 1

if [[ -n "${CM_BUILD_ID:-}" ]]; then
# Codemagic checks out the pushed `ota-*` tag. It must point into main; main
# may have moved on while the build queued. GitHub CI is not queried from
# there, so its check commands run on this commit below.
if ! git merge-base --is-ancestor "$local_head" origin/main; then
print -u2 "production OTA requires a commit on main, not $local_head"
exit 1
fi
verify_mode=local
else
current_branch="$(git branch --show-current)"
if [[ "$current_branch" != "main" ]]; then
print -u2 "production OTA must run from main, not $current_branch"
exit 1
fi
remote_head="$(git rev-parse origin/main)"
if [[ "$local_head" != "$remote_head" ]]; then
print -u2 "production OTA requires HEAD to match origin/main"
exit 1
fi
verify_mode="${OTA_VERIFY:-ci}"
fi

verify_mode="${OTA_VERIFY:-ci}"
if [[ "$verify_mode" == "ci" ]]; then
ci_state="$(
gh run list \
Expand Down Expand Up @@ -75,10 +92,10 @@ else
exit 64
fi

if [[ "${OTA_DRY_RUN:-}" == "1" ]]; then
print "Verified BooKoo $platform OTA release gates for main@$local_head"
exit 0
fi
# A dry run still regenerates the native projects and builds the bundle; only
# the upload is skipped (`release-react --dry-run`).
dry_run=()
[[ "${OTA_DRY_RUN:-}" == "1" ]] && dry_run=(--dry-run)

version="$(bun -e 'process.stdout.write(require("./package.json").version)')"
case "$platform" in
Expand All @@ -90,17 +107,28 @@ esac
for target in $targets; do
app_name="BooKoo-iOS"
[[ "$target" == "android" ]] && app_name="BooKoo-Android"
print "Publishing BooKoo $target OTA $version from main@$local_head"
print "Publishing BooKoo $target OTA $version from $local_head${dry_run:+ (dry run)}"
# The native projects are generated (CNG). Patch fingerprints them and
# refuses a release whose fingerprint differs from earlier releases for the
# same binary version, so they are regenerated from this commit, with the
# store builds' production identity, before every release. `--clean`
# replaces any local ios/ and android/ folders.
prebuild=(bunx expo prebuild --no-install --clean --platform "$target")
release=(
bunx @codemagic/patch-cli@0.10.0 release-react
--server-url https://ota.codemagicpatch.dev
--app "$app_name"
--deployment Production
--platform "$target"
--target-binary-version "$version"
--release-notes "$update_message"
--non-interactive --yes
$dry_run
)
# EAS stays the source of the production environment: `env:exec` injects the
# same EXPO_PUBLIC_* values the store builds were compiled with.
# same EXPO_PUBLIC_* values the store builds were compiled with. Each word is
# quoted because env:exec runs the string through a shell.
production_env="NODE_ENV=production STAGE=production BOOKOO_APP_VARIANT=production EXPO_NO_DOTENV=1"
bunx eas-cli@23.0.0 env:exec production --non-interactive \
"NODE_ENV=production STAGE=production BOOKOO_APP_VARIANT=production EXPO_NO_DOTENV=1 \
bunx @codemagic/patch-cli@0.10.0 release-react \
--server-url https://ota.codemagicpatch.dev \
--app $app_name \
--deployment Production \
--platform $target \
--target-binary-version $version \
--release-notes ${(q)update_message} \
--non-interactive --yes"
"$production_env ${(j: :)${(@q)prebuild}} && $production_env ${(j: :)${(@q)release}}"
done
Loading
Loading