Skip to content

Commit 3f8fd1f

Browse files
committed
refactor: remove beta sync script and update promotion documentation
- Deleted the `sync-develop-to-beta.sh` script as it is no longer needed. - Updated the promotion documentation in `PUBLISH.md` to clarify the workflow and removed references to the beta publish line. - Adjusted the NPM audit allowlist documentation to reflect the removal of the beta sync script.
1 parent 24ac187 commit 3f8fd1f

4 files changed

Lines changed: 77 additions & 177 deletions

File tree

docs/PUBLISH.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Two workflows cover release artifacts:
1212

1313
**GitHub Releases:** Staging prereleases and main production releases get a short auto-generated description. Maintain richer notes on GitHub when needed.
1414

15-
**Promotion:** all product changes land on **`develop`**. **Order:** **`sync-develop-to-staging.sh`**, then (after a green **Publish (staging)**) **`sync-staging-to-main.sh`**. Do **not** update **`main` directly from `develop`**; **`main`** only advances from **`staging`**. There is no **`beta`** publish line.
15+
**Promotion scripts** (under `scripts/publish/`): `sync-develop-to-staging.sh`, then (after a green staging build, when you want RTM) `sync-staging-to-main.sh`. Use **`staging`** for preprod builds and **`main`** to ship. Do **not** update **`main` directly from `develop`**; **`main`** only advances from **`staging`**.
1616

1717
## Runtime config lifecycle (web + management-web)
1818

docs/development/NPM-AUDIT-ALLOWLIST.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Pass comma-separated npm advisory `source` IDs as the first argument to `check-a
4141
- [scripts/publish/bump-version.sh](/scripts/publish/bump-version.sh)
4242
- [scripts/publish/sync-develop-to-staging.sh](/scripts/publish/sync-develop-to-staging.sh)
4343
- [scripts/publish/sync-staging-to-main.sh](/scripts/publish/sync-staging-to-main.sh)
44-
- [scripts/publish/sync-develop-to-beta.sh](/scripts/publish/sync-develop-to-beta.sh)
4544

4645
Keep all call sites **in sync**.
4746

scripts/publish/sync-develop-to-beta.sh

Lines changed: 0 additions & 142 deletions
This file was deleted.
Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# Fast-forward `staging` to match `develop` (triggers the Publish (staging) workflow on push).
33

44
set -e
@@ -14,111 +14,154 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
1414
cd "$REPO_ROOT"
1515

1616
if ! git diff-index --quiet HEAD --; then
17-
echo -e "${RED}Error: You have uncommitted changes. Commit or stash before syncing.${NC}"
17+
echo -e "${RED}Error: You have uncommitted changes. Please commit or stash them first.${NC}"
18+
echo -e "${YELLOW}Run 'git status' to see what needs to be handled.${NC}"
1819
exit 1
1920
fi
2021

2122
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
22-
echo -e "${YELLOW}Warning: Untracked files detected.${NC}"
23+
echo -e "${YELLOW}Warning: You have untracked files. These won't affect the merge but may be unexpected.${NC}"
2324
read -p "Continue anyway? (y/N) " -n 1 -r
2425
echo
2526
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
2627
exit 1
2728
fi
2829
fi
2930

30-
echo -e "${YELLOW}Fetching latest origin refs...${NC}"
31+
echo -e "${YELLOW}Fetching latest from origin...${NC}"
3132
git fetch origin
3233

3334
if ! git show-ref --verify --quiet refs/heads/develop; then
34-
echo -e "${RED}Error: Local branch 'develop' does not exist.${NC}"
35+
echo -e "${RED}Error: Local 'develop' branch does not exist.${NC}"
3536
echo -e "${YELLOW}Run: git checkout -b develop origin/develop${NC}"
3637
exit 1
3738
fi
3839

3940
if ! git show-ref --verify --quiet refs/heads/staging; then
40-
echo -e "${RED}Error: Local branch 'staging' does not exist.${NC}"
41+
echo -e "${RED}Error: Local 'staging' branch does not exist.${NC}"
4142
echo -e "${YELLOW}Run: git checkout -b staging origin/staging${NC}"
4243
exit 1
4344
fi
4445

46+
if ! git show-ref --verify --quiet refs/remotes/origin/develop; then
47+
echo -e "${RED}Error: Remote 'origin/develop' branch does not exist.${NC}"
48+
exit 1
49+
fi
50+
4551
if ! git show-ref --verify --quiet refs/remotes/origin/staging; then
46-
echo -e "${RED}Error: Remote branch 'origin/staging' does not exist.${NC}"
52+
echo -e "${RED}Error: Remote 'origin/staging' branch does not exist.${NC}"
4753
exit 1
4854
fi
4955

50-
CURRENT_BRANCH="$(git branch --show-current)"
51-
echo -e "${YELLOW}Current branch: ${CURRENT_BRANCH}${NC}"
56+
CURRENT_BRANCH=$(git branch --show-current)
57+
echo -e "${YELLOW}Current branch: $CURRENT_BRANCH${NC}"
5258

53-
echo -e "${YELLOW}Updating local develop...${NC}"
59+
echo -e "${YELLOW}Updating local develop to match origin/develop...${NC}"
5460
git switch develop
5561
git merge --ff-only refs/remotes/origin/develop
5662

57-
DEVELOP_COMMIT="$(git rev-parse refs/heads/develop)"
58-
ORIGIN_DEVELOP_COMMIT="$(git rev-parse refs/remotes/origin/develop)"
63+
DEVELOP_COMMIT=$(git rev-parse refs/heads/develop)
64+
ORIGIN_DEVELOP_COMMIT=$(git rev-parse refs/remotes/origin/develop)
65+
5966
if [ "$DEVELOP_COMMIT" != "$ORIGIN_DEVELOP_COMMIT" ]; then
60-
echo -e "${RED}Error: local develop does not match origin/develop after pull.${NC}"
67+
echo -e "${RED}Error: Local develop ($DEVELOP_COMMIT) does not match origin/develop ($ORIGIN_DEVELOP_COMMIT)${NC}"
6168
exit 1
6269
fi
6370

6471
echo -e "${YELLOW}Running security audit on develop (moderate and above; low permitted)...${NC}"
65-
npm ci
72+
echo -e "${YELLOW}Using Linux Docker so npm ci matches CI (linux-canonical lockfile / optional natives).${NC}"
6673

67-
if ! "$SCRIPT_DIR/../lib/check-audit-gate.sh" "" "promote to staging"; then
68-
echo -e "${RED}Error: npm audit failed. Fix before syncing to staging.${NC}"
74+
if ! command -v docker &>/dev/null; then
75+
echo -e "${RED}Error: Docker is required for this step. Install Docker and retry.${NC}"
6976
exit 1
7077
fi
78+
79+
NODE_IMAGE="${SYNC_STAGING_NODE_IMAGE:-node:24}"
80+
DOCKER_PLATFORM="${LOCKFILE_DOCKER_PLATFORM:-linux/amd64}"
81+
82+
if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" && "$DOCKER_PLATFORM" == "linux/amd64" ]]; then
83+
echo -e "${YELLOW}Note: emulated linux/amd64 on Apple Silicon can be slow or fail during optional native installs.${NC}"
84+
echo -e "${YELLOW} If needed: LOCKFILE_DOCKER_PLATFORM=linux/arm64 (see docs/development/tooling/LOCKFILE-LINUX.md).${NC}"
85+
echo ""
86+
fi
87+
88+
if ! docker run --rm \
89+
--platform "$DOCKER_PLATFORM" \
90+
-v "$REPO_ROOT:/app" \
91+
-w /app \
92+
"$NODE_IMAGE" \
93+
bash -c 'npm ci && bash scripts/lib/check-audit-gate.sh "" "promote to staging"'; then
94+
echo -e "${RED}Error: npm ci or npm audit gate failed in Docker. Fix issues before syncing to staging.${NC}"
95+
exit 1
96+
fi
97+
98+
echo -e "${YELLOW}Note: node_modules now matches Linux optional deps from Docker. For local macOS dev, reinstall deps (e.g. rm -rf node_modules && npm install).${NC}"
7199
echo ""
72100

73-
echo -e "${YELLOW}Updating local staging...${NC}"
101+
echo -e "${YELLOW}Updating local staging to match origin/staging...${NC}"
74102
git switch staging
75103
git merge --ff-only refs/remotes/origin/staging
76104

77-
STAGING_COMMIT="$(git rev-parse refs/heads/staging)"
78-
ORIGIN_STAGING_COMMIT="$(git rev-parse refs/remotes/origin/staging)"
105+
STAGING_COMMIT=$(git rev-parse refs/heads/staging)
106+
ORIGIN_STAGING_COMMIT=$(git rev-parse refs/remotes/origin/staging)
107+
79108
if [ "$STAGING_COMMIT" != "$ORIGIN_STAGING_COMMIT" ]; then
80-
echo -e "${RED}Error: local staging does not match origin/staging after pull.${NC}"
109+
echo -e "${RED}Error: Local staging ($STAGING_COMMIT) does not match origin/staging ($ORIGIN_STAGING_COMMIT)${NC}"
81110
exit 1
82111
fi
83112

84-
echo -e "${YELLOW}Checking that staging can fast-forward to develop...${NC}"
113+
echo -e "${YELLOW}Verifying staging can fast-forward merge from develop...${NC}"
85114
if ! git merge-base --is-ancestor refs/heads/staging refs/heads/develop; then
86-
echo -e "${RED}Error: Fast-forward is not possible (staging has commits not in develop).${NC}"
115+
echo -e "${RED}Error: staging is not an ancestor of develop. Fast-forward merge is not possible.${NC}"
116+
echo -e "${YELLOW}Commits in staging but not in develop:${NC}"
87117
git log refs/heads/develop..refs/heads/staging --oneline
88118
exit 1
89119
fi
90120

91121
if [ "$STAGING_COMMIT" == "$DEVELOP_COMMIT" ]; then
92-
echo -e "${GREEN}Staging already matches develop. Nothing to do.${NC}"
122+
echo -e "${GREEN}Staging is already up to date with develop. No merge needed.${NC}"
93123
if [ "$CURRENT_BRANCH" != "staging" ]; then
94124
git checkout "$CURRENT_BRANCH"
95125
fi
96126
exit 0
97127
fi
98128

99-
echo -e "${YELLOW}Merging develop into staging with --ff-only...${NC}"
100-
git merge refs/heads/develop --ff-only
129+
echo -e "${YELLOW}Merging develop into staging (fast-forward only)...${NC}"
130+
if ! git merge refs/heads/develop --ff-only; then
131+
echo -e "${RED}Error: Fast-forward merge failed.${NC}"
132+
exit 1
133+
fi
101134

102-
NEW_STAGING_COMMIT="$(git rev-parse refs/heads/staging)"
135+
NEW_STAGING_COMMIT=$(git rev-parse refs/heads/staging)
103136
if [ "$NEW_STAGING_COMMIT" != "$DEVELOP_COMMIT" ]; then
104-
echo -e "${RED}Error: staging does not match develop after merge.${NC}"
137+
echo -e "${RED}Error: After merge, staging ($NEW_STAGING_COMMIT) does not match develop ($DEVELOP_COMMIT)${NC}"
105138
exit 1
106139
fi
107140

108-
echo -e "${YELLOW}Pushing staging to origin (uses --no-verify)...${NC}"
141+
echo -e "${GREEN}Staging successfully merged with develop.${NC}"
142+
143+
echo -e "${YELLOW}Pushing staging to origin (bypassing hooks)...${NC}"
109144
if ! git push --no-verify origin refs/heads/staging:refs/heads/staging; then
110-
echo -e "${RED}Error: push to origin/staging failed (permissions or use PR develop→staging).${NC}"
145+
echo -e "${RED}Error: Failed to push to origin/staging${NC}"
146+
echo -e "${YELLOW} 1. Missing bypass permissions for protected branch 'staging'${NC}"
147+
echo -e "${YELLOW} 2. Or use a PR from develop to staging${NC}"
111148
exit 1
112149
fi
113150

114-
echo -e "${YELLOW}Final verification...${NC}"
151+
echo -e "${YELLOW}Verifying staging matches develop after push...${NC}"
115152
git fetch origin
116-
if [ "$(git rev-parse refs/remotes/origin/staging)" != "$(git rev-parse refs/remotes/origin/develop)" ]; then
117-
echo -e "${RED}Error: origin/staging does not match origin/develop after push.${NC}"
153+
FINAL_STAGING_COMMIT=$(git rev-parse refs/remotes/origin/staging)
154+
FINAL_DEVELOP_COMMIT=$(git rev-parse refs/remotes/origin/develop)
155+
156+
if [ "$FINAL_STAGING_COMMIT" != "$FINAL_DEVELOP_COMMIT" ]; then
157+
echo -e "${RED}Error: After push, origin/staging ($FINAL_STAGING_COMMIT) does not match origin/develop ($FINAL_DEVELOP_COMMIT)${NC}"
118158
exit 1
119159
fi
120160

121-
echo -e "${GREEN}✓ Staging now mirrors develop and is pushed to origin${NC}"
161+
echo -e "${GREEN}✓ Staging is now a perfect mirror of develop${NC}"
162+
echo -e "${GREEN}✓ Changes pushed to origin/staging${NC}"
163+
122164
if [ "$CURRENT_BRANCH" != "staging" ]; then
165+
echo -e "${YELLOW}Returning to original branch: $CURRENT_BRANCH${NC}"
123166
git checkout "$CURRENT_BRANCH"
124167
fi

0 commit comments

Comments
 (0)