publish_muse_release.sh
bash
sha256:fc04e4cae9e1774d6a21b65c45daeed0e6787eb581d13aa1b03bfe9384a34226
Merge branch 'fix/two-column-scroll-layout' into dev
Human
8 days ago
| 1 | #!/usr/bin/env bash |
| 2 | # Publish a new muse CLI release to staging. |
| 3 | # |
| 4 | # Usage: |
| 5 | # bash deploy/publish_muse_release.sh # builds current version from ~/ecosystem/muse |
| 6 | # MUSE_VERSION=0.2.1 bash deploy/publish_muse_release.sh # override version label |
| 7 | # |
| 8 | # What it does: |
| 9 | # 1. Builds the muse sdist from ~/ecosystem/muse. |
| 10 | # 2. Uploads the tarball to s3://musehub-releases/muse-{version}.tar.gz. |
| 11 | # 3. SSMs to the staging instance to pull the tarball from S3 into /data/releases/. |
| 12 | # 4. Removes stale tarballs from S3 and /data/releases/ (keeps the 3 most recent). |
| 13 | # 5. Verifies the tarball is live via https://staging.musehub.ai/releases/muse-{version}.tar.gz. |
| 14 | # 6. Runs deploy/smoke_muse.sh — installs into a throwaway venv and runs 18 CLI checks. |
| 15 | # |
| 16 | # Prerequisites: |
| 17 | # - Python 3.14 + build package (pip install build) |
| 18 | # - AWS CLI configured (musehub-infra profile or default with the right creds) |
| 19 | # - ~/ecosystem/muse checked out at the version you want to ship |
| 20 | |
| 21 | set -euo pipefail |
| 22 | |
| 23 | SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 24 | MUSE_REPO="${MUSE_REPO:-$HOME/ecosystem/muse}" |
| 25 | S3_BUCKET="musehub-releases" |
| 26 | STAGING_INSTANCE="i-07547cd20bee2dea5" |
| 27 | REGION="us-east-1" |
| 28 | STAGING_URL="https://staging.musehub.ai" |
| 29 | KEEP_RELEASES=3 # number of tarballs to keep on S3 and server |
| 30 | |
| 31 | log() { printf '\033[1;34m%s\033[0m\n' "$*" >&2; } |
| 32 | die() { printf '\033[1;31mERROR: %s\033[0m\n' "$*" >&2; exit 1; } |
| 33 | |
| 34 | # ── 1. Resolve version ──────────────────────────────────────────────────────── |
| 35 | |
| 36 | if [ -z "${MUSE_VERSION:-}" ]; then |
| 37 | MUSE_VERSION=$(python3 -c " |
| 38 | import re, pathlib |
| 39 | t = pathlib.Path('$MUSE_REPO/pyproject.toml').read_text() |
| 40 | m = re.search(r'^version\s*=\s*\"([^\"]+)\"', t, re.MULTILINE) |
| 41 | print(m.group(1)) |
| 42 | ") |
| 43 | fi |
| 44 | |
| 45 | log "[1/5] Building muse $MUSE_VERSION from $MUSE_REPO" |
| 46 | |
| 47 | # ── 2. Build sdist ──────────────────────────────────────────────────────────── |
| 48 | |
| 49 | cd "$MUSE_REPO" |
| 50 | python3 -m build --sdist --outdir dist/ 2>&1 | tail -3 |
| 51 | |
| 52 | TARBALL="dist/muse-${MUSE_VERSION}.tar.gz" |
| 53 | [ -f "$TARBALL" ] || die "Expected tarball not found: $MUSE_REPO/$TARBALL" |
| 54 | log " Built: $(du -sh "$TARBALL" | cut -f1) $TARBALL" |
| 55 | |
| 56 | # ── 3. Upload to S3 ─────────────────────────────────────────────────────────── |
| 57 | |
| 58 | log "[2/5] Uploading to s3://$S3_BUCKET/" |
| 59 | aws s3 cp "$TARBALL" "s3://$S3_BUCKET/muse-${MUSE_VERSION}.tar.gz" |
| 60 | |
| 61 | # ── 4. Pull from S3 into /data/releases/ on staging ───────────────────────── |
| 62 | |
| 63 | log "[3/5] Pushing to staging ($STAGING_INSTANCE)" |
| 64 | |
| 65 | CMD="aws s3 cp s3://$S3_BUCKET/muse-${MUSE_VERSION}.tar.gz /tmp/muse-${MUSE_VERSION}.tar.gz && \ |
| 66 | docker run --rm -v musehub_data:/data -v /tmp:/src alpine sh -c \ |
| 67 | 'mkdir -p /data/releases && cp /src/muse-${MUSE_VERSION}.tar.gz /data/releases/muse-${MUSE_VERSION}.tar.gz'" |
| 68 | |
| 69 | CMD_ID=$(aws ssm send-command \ |
| 70 | --region "$REGION" \ |
| 71 | --instance-ids "$STAGING_INSTANCE" \ |
| 72 | --document-name "AWS-RunShellScript" \ |
| 73 | --parameters "commands=[\"$CMD\"]" \ |
| 74 | --comment "publish muse $MUSE_VERSION" \ |
| 75 | --timeout-seconds 120 \ |
| 76 | --query "Command.CommandId" \ |
| 77 | --output text) |
| 78 | |
| 79 | log " SSM command: $CMD_ID — polling..." |
| 80 | |
| 81 | for i in $(seq 1 24); do |
| 82 | sleep 5 |
| 83 | STATUS=$(aws ssm get-command-invocation \ |
| 84 | --region "$REGION" \ |
| 85 | --command-id "$CMD_ID" \ |
| 86 | --instance-id "$STAGING_INSTANCE" \ |
| 87 | --query "Status" \ |
| 88 | --output text 2>/dev/null || echo "Pending") |
| 89 | case "$STATUS" in |
| 90 | Success) log " ✅ Staging copy succeeded."; break ;; |
| 91 | Failed|Cancelled|TimedOut) die "SSM command $STATUS" ;; |
| 92 | *) printf '.' >&2 ;; |
| 93 | esac |
| 94 | done |
| 95 | [ "$STATUS" = "Success" ] || die "SSM timed out (status: $STATUS)" |
| 96 | |
| 97 | # ── 5. Clean up old releases (S3 + server, keep newest KEEP_RELEASES) ──────── |
| 98 | |
| 99 | log "[4/5] Cleaning up old releases (keeping $KEEP_RELEASES newest)" |
| 100 | |
| 101 | # S3 cleanup — list, prune via PEP 440 precedence (packaging.version.Version, |
| 102 | # not sort -V's lexical comparison -- see issue #128), delete the stale set. |
| 103 | STALE_S3=$(aws s3 ls "s3://$S3_BUCKET/" \ |
| 104 | | awk '{print $NF}' \ |
| 105 | | grep '^muse-.*\.tar\.gz$' \ |
| 106 | | xargs -r python3 "$SCRIPT_DIR/prune_releases.py" --keep "$KEEP_RELEASES") |
| 107 | |
| 108 | if [ -n "$STALE_S3" ]; then |
| 109 | while IFS= read -r key; do |
| 110 | log " Deleting s3://$S3_BUCKET/$key" |
| 111 | aws s3 rm "s3://$S3_BUCKET/$key" |
| 112 | done <<< "$STALE_S3" |
| 113 | else |
| 114 | log " S3: nothing to remove." |
| 115 | fi |
| 116 | |
| 117 | # Server cleanup — list remotely, compute the stale set LOCALLY with the same |
| 118 | # prune_releases.py call (Python/packaging availability on the bare EC2 host |
| 119 | # is not guaranteed), then send an explicit rm of the exact stale filenames. |
| 120 | # The remote shell never sorts or re-implements precedence logic itself. |
| 121 | LIST_CMD_ID=$(aws ssm send-command \ |
| 122 | --region "$REGION" \ |
| 123 | --instance-ids "$STAGING_INSTANCE" \ |
| 124 | --document-name "AWS-RunShellScript" \ |
| 125 | --parameters 'commands=["ls /data/releases/muse-*.tar.gz 2>/dev/null | xargs -n1 basename"]' \ |
| 126 | --comment "list muse releases for pruning" \ |
| 127 | --output text \ |
| 128 | --query "Command.CommandId") |
| 129 | |
| 130 | for i in $(seq 1 24); do |
| 131 | sleep 2 |
| 132 | LIST_STATUS=$(aws ssm get-command-invocation \ |
| 133 | --region "$REGION" \ |
| 134 | --command-id "$LIST_CMD_ID" \ |
| 135 | --instance-id "$STAGING_INSTANCE" \ |
| 136 | --query "Status" \ |
| 137 | --output text 2>/dev/null || echo "Pending") |
| 138 | case "$LIST_STATUS" in |
| 139 | Success) break ;; |
| 140 | Failed|Cancelled|TimedOut) die "SSM list command $LIST_STATUS" ;; |
| 141 | *) printf '.' >&2 ;; |
| 142 | esac |
| 143 | done |
| 144 | [ "$LIST_STATUS" = "Success" ] || die "SSM list command timed out (status: $LIST_STATUS)" |
| 145 | |
| 146 | REMOTE_FILES=$(aws ssm get-command-invocation \ |
| 147 | --region "$REGION" \ |
| 148 | --command-id "$LIST_CMD_ID" \ |
| 149 | --instance-id "$STAGING_INSTANCE" \ |
| 150 | --query "StandardOutputContent" \ |
| 151 | --output text) |
| 152 | |
| 153 | STALE_SERVER=$(printf '%s' "$REMOTE_FILES" | xargs -r python3 "$SCRIPT_DIR/prune_releases.py" --keep "$KEEP_RELEASES") |
| 154 | |
| 155 | if [ -n "$STALE_SERVER" ]; then |
| 156 | RM_ARGS=$(printf '%s\n' "$STALE_SERVER" | sed 's#^#/data/releases/#' | tr '\n' ' ') |
| 157 | aws ssm send-command \ |
| 158 | --region "$REGION" \ |
| 159 | --instance-ids "$STAGING_INSTANCE" \ |
| 160 | --document-name "AWS-RunShellScript" \ |
| 161 | --parameters "commands=[\"rm -v $RM_ARGS\"]" \ |
| 162 | --comment "prune stale muse releases" \ |
| 163 | --output text \ |
| 164 | --query "Command.CommandId" > /dev/null |
| 165 | else |
| 166 | log " Server: nothing to remove." |
| 167 | fi |
| 168 | |
| 169 | # ── 6. Smoke-test: verify tarball is live ───────────────────────────────────── |
| 170 | |
| 171 | log "[5/5] Verifying $STAGING_URL/releases/muse-${MUSE_VERSION}.tar.gz" |
| 172 | |
| 173 | HTTP=$(curl -sI "$STAGING_URL/releases/muse-${MUSE_VERSION}.tar.gz" \ |
| 174 | | grep -i "^HTTP" | awk '{print $2}') |
| 175 | |
| 176 | if [ "$HTTP" = "200" ]; then |
| 177 | log " ✅ Live at $STAGING_URL/releases/muse-${MUSE_VERSION}.tar.gz" |
| 178 | else |
| 179 | die "Expected HTTP 200, got: $HTTP" |
| 180 | fi |
| 181 | |
| 182 | # ── 7. Full smoke test ──────────────────────────────────────────────────────── |
| 183 | |
| 184 | log "[6/6] Running smoke test against $STAGING_URL" |
| 185 | bash "$SCRIPT_DIR/smoke_muse.sh" --url "$STAGING_URL" --version "$MUSE_VERSION" |
| 186 | |
| 187 | log "" |
| 188 | log "muse $MUSE_VERSION is live. Install with:" |
| 189 | log " curl -fsSL $STAGING_URL/install.sh | sh" |
File History
13 commits
sha256:fc04e4cae9e1774d6a21b65c45daeed0e6787eb581d13aa1b03bfe9384a34226
Merge branch 'fix/two-column-scroll-layout' into dev
Human
8 days ago
sha256:408916fc5973ba59c6e4eebaa80ebdcc801c0a63205651e25009d11548f79454
chore: bump version to 0.2.0.dev2 — nightly.2, matching muse
Sonnet 4.6
patch
11 days ago
sha256:d035733f21ccff27735fddebfbbe0ed24565a32a22db8de5885402262671ecd2
chore: bump version to 0.2.0rc15 for musehub#113 fix release
Sonnet 4.6
patch
14 days ago
sha256:0032d6cfa33bc3c8367436ad768e7dd0e339b4332153160247da8266cb5fa352
Merge branch 'task/version-tags-phase3-server' into dev
Human
17 days ago
sha256:4669620efda9ff41c55bdefd1f7bfe1c239d468428744c84ead9957e5a003a53
merge: rescue snapshot-recovery hardening (c00aa21d) into d…
Opus 4.8
minor
⚠
29 days ago
sha256:a59da49c4611b970fc4b6ae48678ce4943261c213a07ddbd73ce9201df869b4a
fix: remove false-positive proposal_comments index drop fro…
Sonnet 4.6
patch
34 days ago
sha256:0a240d6dbff234f07d98a28a4a9a68db702f3f9ff9260196f24219bdb1c0b6f3
feat: render markdown mists as HTML with heading anchor links
Sonnet 4.6
patch
34 days ago
sha256:24a7d47486ebc4ebd1832830580e177ec6f877b48dced8c000e198cdec4ce9d6
Merge 'task/bump-version-rc12' into 'dev' — proposal: Bump …
Human
35 days ago
sha256:b9ff931d147e0114a1f17060f415b89ed551c170a91ff226c70437aa5c85f9ee
Merge 'task/bump-version-rc12' into 'dev' — proposal: Bump …
Human
35 days ago
sha256:d1122d21e73471879b460037b22c0b50fded7c423444a176f248428f75dac39c
Merge 'task/fix-issue-pagination-cursor' into 'dev' — propo…
Human
35 days ago
sha256:01e18975e73d2b3cd5b6db7929c895bef9aa6e0d4391dc5b2adfc548b41318dd
Merge 'feat/adding-debug-logs-to-staging' into 'dev' — prop…
Human
36 days ago
sha256:6b1949fc2797ca4c1936a637a4cbfec828ef56cf52398a2e74ca3c4f494e728f
fix: use wire_bytes not mpack_bytes_raw in compute_object_b…
Sonnet 4.6
patch
48 days ago
sha256:b99f2455dc346966d040133f5203297e6e3ef5803a93728a2c30568d0a0f7583
rename: delta_add → delta_upsert across wire format, models…
Sonnet 4.6
patch
50 days ago