-
Notifications
You must be signed in to change notification settings - Fork 0
201 lines (173 loc) · 6.9 KB
/
Copy pathrelease.yml
File metadata and controls
201 lines (173 loc) · 6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: Release
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
verify:
name: Verify (lint, unit, build, e2e)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
# Required because src/stores/profile.ts imports types from
# ../../../dashboard-app/frontend/types/database.type — see CLAUDE.md.
- name: Checkout sibling dashboard-app
run: git clone --depth 1 https://github.com/codebridger/subturtle-dashboard-app.git ../dashboard-app
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
playwright-${{ runner.os }}-
- name: Install Playwright Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium --with-deps
- name: Install Playwright system deps (cache hit path)
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium
- name: Type check
run: yarn typecheck
- name: Unit tests (Vitest)
run: yarn test
# dotenv-webpack is configured with `safe: true`, so the build needs
# every key in .env.example to exist at build time. We write
# non-empty placeholders rather than copying the empty .env.example
# — `mixpanel.init("")` throws synchronously during the content-script
# import chain, which silently halts every Vue mount and was the root
# cause of e2e tests failing on `#subturtle-{nibble,console-crane}-root`
# never appearing. SUBTURTLE_API_URL points at the local fixtures
# server so any auth/translate calls 404 instead of escaping to the
# real backend.
- name: Stub .env.production for verify build
run: |
cat > .env.production <<'EOF'
MIXPANEL_PROJECT_TOKEN=ci_e2e_stub_token
MIXPANEL_API_HOST=http://localhost:4173/_mixpanel_stub
GOOGLE_TRANSLATE_KEY=ci_e2e_stub_key
GOOGLE_TRANSLATE_PROXY_URL=http://localhost:4173/_translate_proxy_stub
UNINSTALL_FORM_URL=http://localhost:4173/_uninstall_stub
SUBTURTLE_API_URL=http://localhost:4173
SUBTURTLE_DASHBOARD_URL=http://localhost:4173/_dashboard_stub
GOOGLE_OAUTH_CLIENT_ID=ci_e2e_stub_oauth_client
EOF
- name: Build extension
run: yarn build
- name: E2E tests (Playwright)
run: yarn test:e2e
- name: Upload Playwright report
# Run on both success and failure (anything except job cancel) so
# the HTML report is downloadable for green runs too. The
# hashFiles guard skips silently when typecheck or unit tests
# failed before Playwright produced any output.
if: ${{ !cancelled() && hashFiles('playwright-report/**') != '' }}
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 7
release:
name: Release
needs: verify
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Checkout sibling dashboard-app
run: git clone --depth 1 https://github.com/codebridger/subturtle-dashboard-app.git ../dashboard-app
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Determine next version
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEXT=$(node scripts/next-version.mjs)
if [ "$NEXT" = "NONE" ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "::notice::No releasable commits since last tag — skipping release."
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "version=$NEXT" >> "$GITHUB_OUTPUT"
echo "::notice::Next version will be $NEXT"
fi
- name: Write .env.production from secrets
if: steps.version.outputs.skip != 'true'
env:
MIXPANEL_PROJECT_TOKEN: ${{ secrets.MIXPANEL_PROJECT_TOKEN }}
GOOGLE_OAUTH_CLIENT_ID: ${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}
GOOGLE_TRANSLATE_KEY: ${{ secrets.GOOGLE_TRANSLATE_KEY }}
MIXPANEL_API_HOST: ${{ vars.MIXPANEL_API_HOST }}
GOOGLE_TRANSLATE_PROXY_URL: ${{ vars.GOOGLE_TRANSLATE_PROXY_URL }}
UNINSTALL_FORM_URL: ${{ vars.UNINSTALL_FORM_URL }}
SUBTURTLE_API_URL: ${{ vars.SUBTURTLE_API_URL }}
SUBTURTLE_DASHBOARD_URL: ${{ vars.SUBTURTLE_DASHBOARD_URL }}
run: |
cat > .env.production <<EOF
MIXPANEL_PROJECT_TOKEN=${MIXPANEL_PROJECT_TOKEN}
MIXPANEL_API_HOST=${MIXPANEL_API_HOST}
GOOGLE_TRANSLATE_KEY=${GOOGLE_TRANSLATE_KEY}
GOOGLE_TRANSLATE_PROXY_URL=${GOOGLE_TRANSLATE_PROXY_URL}
UNINSTALL_FORM_URL=${UNINSTALL_FORM_URL}
SUBTURTLE_API_URL=${SUBTURTLE_API_URL}
SUBTURTLE_DASHBOARD_URL=${SUBTURTLE_DASHBOARD_URL}
GOOGLE_OAUTH_CLIENT_ID=${GOOGLE_OAUTH_CLIENT_ID}
EOF
- name: Bump versions for build
if: steps.version.outputs.skip != 'true'
run: |
npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version
node scripts/sync-manifest-version.mjs "${{ steps.version.outputs.version }}"
- name: Build
if: steps.version.outputs.skip != 'true'
run: yarn build
- name: Zip
if: steps.version.outputs.skip != 'true'
run: yarn zip
- name: Restore version files for clean release commit
if: steps.version.outputs.skip != 'true'
run: git checkout -- package.json static/manifest.json
- name: Release
if: steps.version.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn release
- name: Upload zip artifact
if: steps.version.outputs.skip != 'true' && hashFiles('subturtle.zip') != ''
uses: actions/upload-artifact@v4
with:
name: subturtle-extension
path: subturtle.zip