canister-release-prep.sh
bash
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
1 day ago
| 1 | #!/usr/bin/env bash |
| 2 | # |
| 3 | # One-shot preparation before upgrading the hub canister on mainnet. |
| 4 | # Runs: optional git sync → migration shape check → npm test → dfx build → optional vault export backup. |
| 5 | # Does NOT run dfx deploy (you run that after this succeeds). |
| 6 | # |
| 7 | # Usage (from anywhere): |
| 8 | # cd /path/to/knowtation |
| 9 | # npm run canister:release-prep |
| 10 | # |
| 11 | # Sync to latest main first (fails if working tree is not clean): |
| 12 | # npm run canister:release-prep -- --sync-main |
| 13 | # |
| 14 | # Environment (optional; also loaded from repo-root .env if present): |
| 15 | # KNOWTATION_CANISTER_URL — e.g. https://<canister-id>.icp0.io (no trailing slash) |
| 16 | # KNOWTATION_CANISTER_BACKUP_USER_ID — Hub user id (e.g. google:123) for GET /api/v1/export backup |
| 17 | # KNOWTATION_CANISTER_BACKUP_VAULT_ID — default: default |
| 18 | # |
| 19 | # If BACKUP_USER_ID is set but URL is not, the script defaults URL from hub/icp/canister_ids.json (ic + .icp0.io). |
| 20 | # |
| 21 | # Escape hatches (passed through to canister-predeploy.sh): |
| 22 | # SKIP_NPM_TEST=1 npm run canister:release-prep |
| 23 | # SKIP_DFX_BUILD=1 npm run canister:release-prep |
| 24 | # |
| 25 | set -euo pipefail |
| 26 | |
| 27 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 28 | REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" |
| 29 | cd "$REPO_ROOT" |
| 30 | |
| 31 | export NO_COLOR="${NO_COLOR:-}" |
| 32 | export CI="${CI:-}" |
| 33 | export TERM="${TERM:-}" |
| 34 | |
| 35 | SYNC_MAIN=0 |
| 36 | for arg in "$@"; do |
| 37 | case "$arg" in |
| 38 | --sync-main) SYNC_MAIN=1 ;; |
| 39 | -h | --help) |
| 40 | sed -n '2,40p' "$0" | sed 's/^# \{0,1\}//' |
| 41 | exit 0 |
| 42 | ;; |
| 43 | *) |
| 44 | echo "Unknown option: $arg (use --sync-main or --help)" |
| 45 | exit 1 |
| 46 | ;; |
| 47 | esac |
| 48 | done |
| 49 | |
| 50 | if [[ -f "$REPO_ROOT/.env" ]]; then |
| 51 | echo "==> Loading repo-root .env (for backup / tool env)" |
| 52 | set -a |
| 53 | # shellcheck disable=SC1091 |
| 54 | source "$REPO_ROOT/.env" |
| 55 | set +a |
| 56 | fi |
| 57 | |
| 58 | if [[ "$SYNC_MAIN" == 1 ]]; then |
| 59 | echo "==> [0/5] Git: checkout main and pull (requires clean working tree)" |
| 60 | if [[ -n "$(git status --porcelain 2>/dev/null)" ]]; then |
| 61 | echo "ERROR: Working tree is not clean. Commit, stash, or discard changes, then retry." |
| 62 | exit 1 |
| 63 | fi |
| 64 | git fetch origin main |
| 65 | git checkout main |
| 66 | git pull origin main |
| 67 | echo " On branch $(git branch --show-current) @ $(git rev-parse --short HEAD)" |
| 68 | fi |
| 69 | |
| 70 | if [[ -n "${KNOWTATION_CANISTER_BACKUP_USER_ID:-}" && -z "${KNOWTATION_CANISTER_URL:-}" ]]; then |
| 71 | echo "==> Defaulting KNOWTATION_CANISTER_URL from hub/icp/canister_ids.json" |
| 72 | KNOWTATION_CANISTER_URL="$( |
| 73 | node -e " |
| 74 | const fs = require('fs'); |
| 75 | const p = 'hub/icp/canister_ids.json'; |
| 76 | const j = JSON.parse(fs.readFileSync(p, 'utf8')); |
| 77 | const id = j.hub && j.hub.ic; |
| 78 | if (!id) throw new Error('Missing hub.ic in canister_ids.json'); |
| 79 | process.stdout.write('https://' + id + '.icp0.io'); |
| 80 | " |
| 81 | )" |
| 82 | export KNOWTATION_CANISTER_URL |
| 83 | echo " Using: $KNOWTATION_CANISTER_URL (override KNOWTATION_CANISTER_URL if your gateway uses another host)" |
| 84 | fi |
| 85 | |
| 86 | echo "==> [1–4/5] canister-predeploy (migration + tests + dfx build + optional backup)" |
| 87 | bash "$REPO_ROOT/scripts/canister-predeploy.sh" |
| 88 | |
| 89 | echo "" |
| 90 | echo "==> [5/5] Done. When ready to upgrade mainnet:" |
| 91 | echo " cd hub/icp && dfx identity use <your-deploy-identity> && dfx deploy hub --network ic" |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
1 day ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
1 day ago