Skip to content

Commit 7aa8cbf

Browse files
committed
ci(release): add workflow to deprecate version
1 parent 917a354 commit 7aa8cbf

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Deprecate package versions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to deprecate (e.g. 2.80.0, 2.80.0-canary.0)'
8+
required: true
9+
type: string
10+
message:
11+
description: 'Deprecation message'
12+
required: true
13+
type: string
14+
15+
env:
16+
NODE_VERSION: '20'
17+
18+
jobs:
19+
deprecate:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
id-token: write
24+
25+
steps:
26+
- name: Generate token
27+
id: app-token
28+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf
29+
with:
30+
app-id: ${{ secrets.APP_ID }}
31+
private-key: ${{ secrets.PRIVATE_KEY }}
32+
33+
- name: Check if actor is member of admin or sdk team
34+
id: team-check
35+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
36+
with:
37+
github-token: ${{ steps.app-token.outputs.token }}
38+
script: |
39+
const org = 'supabase'
40+
const { actor } = context
41+
42+
async function isTeamMember(team_slug) {
43+
try {
44+
const res = await github.rest.teams.getMembershipForUserInOrg({
45+
org,
46+
team_slug,
47+
username: actor,
48+
})
49+
return res && res.status === 200
50+
} catch (_) {
51+
return false
52+
}
53+
}
54+
const isAdmin = await isTeamMember('admin')
55+
const isSdk = await isTeamMember('sdk')
56+
const isMember = isAdmin || isSdk
57+
core.setOutput('is_team_member', isMember ? 'true' : 'false')
58+
59+
- name: Fail if not authorized
60+
if: ${{ steps.team-check.outputs.is_team_member != 'true' }}
61+
run: |
62+
echo "You must be a member of @supabase/admin or @supabase/sdk."
63+
exit 1
64+
65+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
66+
with:
67+
node-version: ${{ env.NODE_VERSION }}
68+
registry-url: 'https://registry.npmjs.org'
69+
70+
- name: Update npm
71+
run: npm install -g npm@latest
72+
73+
- name: Deprecate package versions
74+
env:
75+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
76+
run: |
77+
VERSION="${{ inputs.version }}"
78+
MESSAGE="${{ inputs.message }}"
79+
80+
PACKAGES=(
81+
"supabase-js"
82+
"auth-js"
83+
"functions-js"
84+
"realtime-js"
85+
"storage-js"
86+
"postgrest-js"
87+
"gotrue-js"
88+
)
89+
90+
FAILED=0
91+
92+
for pkg in "${PACKAGES[@]}"; do
93+
FULL_PKG="@supabase/${pkg}"
94+
95+
echo "============================================"
96+
echo "Deprecating ${FULL_PKG}@${VERSION}"
97+
echo "Message: ${MESSAGE}"
98+
echo "============================================"
99+
100+
if npm deprecate "${FULL_PKG}@${VERSION}" "${MESSAGE}"; then
101+
echo "✅ Successfully deprecated ${FULL_PKG}@${VERSION}"
102+
else
103+
echo "❌ Failed to deprecate ${FULL_PKG}@${VERSION}"
104+
FAILED=$((FAILED + 1))
105+
fi
106+
107+
echo ""
108+
done
109+
110+
if [ "$FAILED" -gt 0 ]; then
111+
echo "⚠️ ${FAILED} package(s) failed to deprecate."
112+
exit 1
113+
fi
114+
115+
echo "🎉 All packages deprecated successfully!"
116+
117+
notify-success:
118+
needs: deprecate
119+
if: success()
120+
uses: ./.github/workflows/slack-notify.yml
121+
with:
122+
title: 'SDK Deprecation'
123+
status: 'success'
124+
version: ${{ inputs.version }}
125+
secrets: inherit
126+
127+
notify-failure:
128+
needs: deprecate
129+
if: failure()
130+
uses: ./.github/workflows/slack-notify.yml
131+
with:
132+
title: 'SDK Deprecation'
133+
status: 'failure'
134+
version: ${{ inputs.version }}
135+
secrets: inherit

0 commit comments

Comments
 (0)