Skip to content

Commit 61fefa3

Browse files
authored
Merge pull request #13 from flashcatcloud/chore/release-safety-automation
chore: restore release safety baseline
2 parents a5117c3 + 3fa1022 commit 61fefa3

64 files changed

Lines changed: 714 additions & 335 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Browser SDK CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- publish
8+
push:
9+
branches:
10+
- main
11+
- publish
12+
workflow_dispatch:
13+
14+
env:
15+
NODE_VERSION: '23.11.1'
16+
17+
jobs:
18+
quality:
19+
name: Build, lint, typecheck
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ env.NODE_VERSION }}
29+
30+
- name: Install dependencies
31+
run: yarn install --immutable
32+
33+
- name: Check formatting
34+
run: yarn format
35+
36+
- name: Build packages
37+
run: yarn build
38+
39+
- name: Lint packages
40+
run: yarn lint
41+
42+
- name: Check package metadata
43+
run: node scripts/check-packages.js
44+
45+
- name: Typecheck packages and test apps
46+
run: |
47+
yarn typecheck
48+
scripts/cli typecheck test/apps/vanilla
49+
scripts/cli typecheck test/e2e
50+
51+
unit:
52+
name: Unit tests
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Setup Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: ${{ env.NODE_VERSION }}
62+
63+
- name: Install dependencies
64+
run: yarn install --immutable
65+
66+
- name: Run unit tests
67+
run: yarn test:unit --single-run
68+
69+
compatibility:
70+
name: Compatibility checks
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout code
74+
uses: actions/checkout@v4
75+
76+
- name: Setup Node.js
77+
uses: actions/setup-node@v4
78+
with:
79+
node-version: ${{ env.NODE_VERSION }}
80+
81+
- name: Install dependencies
82+
run: yarn install --immutable
83+
84+
- name: Check TypeScript compatibility
85+
run: yarn test:compat:tsc
86+
87+
- name: Check server-side rendering compatibility
88+
run: yarn test:compat:ssr
89+
90+
bundle:
91+
name: Bundle and script tests
92+
runs-on: ubuntu-latest
93+
env:
94+
BUILD_MODE: release
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
99+
- name: Setup Node.js
100+
uses: actions/setup-node@v4
101+
with:
102+
node-version: ${{ env.NODE_VERSION }}
103+
104+
- name: Install dependencies
105+
run: yarn install --immutable
106+
107+
- name: Build release bundles
108+
run: yarn build:bundle
109+
110+
- name: Run script tests
111+
run: yarn test:script
112+
113+
e2e:
114+
name: Chromium e2e
115+
runs-on: ubuntu-latest
116+
env:
117+
FORCE_COLOR: '1'
118+
steps:
119+
- name: Checkout code
120+
uses: actions/checkout@v4
121+
122+
- name: Setup Node.js
123+
uses: actions/setup-node@v4
124+
with:
125+
node-version: ${{ env.NODE_VERSION }}
126+
127+
- name: Install dependencies
128+
run: yarn install --immutable
129+
130+
- name: Run Chromium e2e tests
131+
run: yarn test:e2e:ci

.github/workflows/deploy-auto.yml

Lines changed: 63 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ on:
55
tags:
66
- 'v*' # 当推送带有 v 前缀的标签时触发
77

8+
env:
9+
NODE_VERSION: '23.11.1'
10+
BUILD_MODE: release
11+
812
jobs:
9-
deploy-prod:
13+
preflight:
14+
name: Release preflight
1015
runs-on: ubuntu-latest
1116
steps:
1217
- name: Checkout code
@@ -15,26 +20,70 @@ jobs:
1520
- name: Setup Node.js
1621
uses: actions/setup-node@v4
1722
with:
18-
node-version: '18'
23+
node-version: ${{ env.NODE_VERSION }}
1924

2025
- name: Install dependencies
21-
run: yarn
26+
run: yarn install --immutable
2227

23-
- name: Export BUILD_MODE
24-
run: export BUILD_MODE=release
28+
- name: Validate tag matches package version
29+
run: |
30+
FULL_VERSION=$(node -p "require('./lerna.json').version")
31+
TAG_VERSION="${GITHUB_REF_NAME#v}"
32+
if [ "$FULL_VERSION" != "$TAG_VERSION" ]; then
33+
echo "Tag v$TAG_VERSION does not match lerna.json version $FULL_VERSION"
34+
exit 1
35+
fi
2536
26-
- name: Get version
37+
- name: Check release metadata
38+
run: node scripts/release/check-release.js
39+
40+
- name: Run release checks
2741
run: |
28-
FULL_VERSION=$(node -p -e "require('./lerna.json').version")
29-
MAJOR_VERSION=$(echo $FULL_VERSION | cut -d. -f1)
30-
echo "VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
31-
echo "version=$MAJOR_VERSION" >> $GITHUB_OUTPUT
32-
env:
33-
BUILD_MODE: release
42+
yarn format
43+
yarn build
44+
yarn lint
45+
node scripts/check-packages.js
46+
yarn typecheck
47+
yarn test:unit --single-run
48+
yarn test:compat:tsc
49+
yarn test:compat:ssr
3450
3551
- name: Build bundle
3652
run: yarn build:bundle
3753

54+
- name: Upload bundle artifact
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: release-bundles
58+
path: packages/*/bundle/**
59+
if-no-files-found: error
60+
61+
deploy-prod:
62+
needs: preflight
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: ${{ env.NODE_VERSION }}
72+
73+
- name: Install dependencies
74+
run: yarn install --immutable
75+
76+
- name: Download verified bundle artifact
77+
uses: actions/download-artifact@v4
78+
with:
79+
name: release-bundles
80+
path: packages
81+
82+
- name: Get version
83+
run: |
84+
FULL_VERSION=$(node -p "require('./lerna.json').version")
85+
echo "VERSION=$FULL_VERSION" >> $GITHUB_ENV
86+
3887
- name: Deploy to prod
3988
run: node ./scripts/deploy/deploy-oss.js prod v${VERSION}
4089
env:
@@ -54,11 +103,11 @@ jobs:
54103
- name: Setup Node.js
55104
uses: actions/setup-node@v4
56105
with:
57-
node-version: '18'
106+
node-version: ${{ env.NODE_VERSION }}
58107
registry-url: 'https://registry.npmjs.org/'
59108

60109
- name: Install dependencies
61-
run: yarn
110+
run: yarn install --immutable
62111

63112
- name: Publish to NPM
64113
run: node ./scripts/deploy/publish-npm.js

.github/workflows/deploy-manual.yml

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,25 @@ on:
88
required: true
99
default: 'no'
1010

11+
env:
12+
NODE_VERSION: '23.11.1'
13+
BUILD_MODE: release
14+
1115
jobs:
12-
deploy-prod:
16+
validate-confirmation:
17+
name: Validate manual confirmation
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Require explicit confirmation
21+
run: |
22+
if [ "${{ github.event.inputs.confirm_deploy }}" != "yes" ]; then
23+
echo 'Deployment blocked: confirm_deploy must be exactly "yes".'
24+
exit 1
25+
fi
26+
27+
preflight:
28+
name: Release preflight
29+
needs: validate-confirmation
1330
runs-on: ubuntu-latest
1431
steps:
1532
- name: Checkout code
@@ -18,26 +35,61 @@ jobs:
1835
- name: Setup Node.js
1936
uses: actions/setup-node@v4
2037
with:
21-
node-version: '18'
38+
node-version: ${{ env.NODE_VERSION }}
2239

2340
- name: Install dependencies
24-
run: yarn
41+
run: yarn install --immutable
2542

26-
- name: Export BUILD_MODE
27-
run: export BUILD_MODE=release
43+
- name: Check release metadata
44+
run: node scripts/release/check-release.js
2845

29-
- name: Get version
46+
- name: Run release checks
3047
run: |
31-
FULL_VERSION=$(node -p -e "require('./lerna.json').version")
32-
MAJOR_VERSION=$(echo $FULL_VERSION | cut -d. -f1)
33-
echo "VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
34-
echo "version=$MAJOR_VERSION" >> $GITHUB_OUTPUT
35-
env:
36-
BUILD_MODE: release
48+
yarn format
49+
yarn build
50+
yarn lint
51+
node scripts/check-packages.js
52+
yarn typecheck
53+
yarn test:unit --single-run
54+
yarn test:compat:tsc
55+
yarn test:compat:ssr
3756
3857
- name: Build bundle
3958
run: yarn build:bundle
4059

60+
- name: Upload bundle artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: release-bundles
64+
path: packages/*/bundle/**
65+
if-no-files-found: error
66+
67+
deploy-prod:
68+
needs: preflight
69+
runs-on: ubuntu-latest
70+
steps:
71+
- name: Checkout code
72+
uses: actions/checkout@v4
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
79+
- name: Install dependencies
80+
run: yarn install --immutable
81+
82+
- name: Download verified bundle artifact
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: release-bundles
86+
path: packages
87+
88+
- name: Get version
89+
run: |
90+
FULL_VERSION=$(node -p "require('./lerna.json').version")
91+
echo "VERSION=$FULL_VERSION" >> $GITHUB_ENV
92+
4193
- name: Deploy to prod
4294
run: node ./scripts/deploy/deploy-oss.js prod v${VERSION}
4395
env:
@@ -57,17 +109,17 @@ jobs:
57109
- name: Setup Node.js
58110
uses: actions/setup-node@v4
59111
with:
60-
node-version: '18'
112+
node-version: ${{ env.NODE_VERSION }}
61113
registry-url: 'https://registry.npmjs.org/'
62114

63115
- name: Install dependencies
64-
run: yarn
116+
run: yarn install --immutable
65117

66118
- name: Publish to NPM
67119
run: node ./scripts/deploy/publish-npm.js
68120
env:
69121
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70-
122+
71123
notify-success:
72124
needs: publish-npm
73125
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)