-
Notifications
You must be signed in to change notification settings - Fork 618
134 lines (114 loc) · 3.74 KB
/
deprecate-version.yml
File metadata and controls
134 lines (114 loc) · 3.74 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
name: Deprecate package versions
on:
workflow_dispatch:
inputs:
version:
description: 'Version to deprecate (e.g. 2.80.0, 2.80.0-canary.0)'
required: true
type: string
message:
description: 'Deprecation message'
required: true
type: string
env:
NODE_VERSION: '20'
jobs:
deprecate:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Generate token
id: app-token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Check if actor is member of admin or sdk team
id: team-check
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const org = 'supabase'
const { actor } = context
async function isTeamMember(team_slug) {
try {
const res = await github.rest.teams.getMembershipForUserInOrg({
org,
team_slug,
username: actor,
})
return res && res.status === 200
} catch (_) {
return false
}
}
const isAdmin = await isTeamMember('admin')
const isSdk = await isTeamMember('sdk')
const isMember = isAdmin || isSdk
core.setOutput('is_team_member', isMember ? 'true' : 'false')
- name: Fail if not authorized
if: ${{ steps.team-check.outputs.is_team_member != 'true' }}
run: |
echo "You must be a member of @supabase/admin or @supabase/sdk."
exit 1
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Update npm
run: npm install -g npm@latest
- name: Deprecate package versions
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ inputs.version }}
MESSAGE: ${{ inputs.message }}
run: |
PACKAGES=(
"supabase-js"
"auth-js"
"functions-js"
"realtime-js"
"storage-js"
"postgrest-js"
"gotrue-js"
)
FAILED=0
for pkg in "${PACKAGES[@]}"; do
FULL_PKG="@supabase/${pkg}"
echo "============================================"
echo "Deprecating ${FULL_PKG}@${VERSION}"
echo "Message: ${MESSAGE}"
echo "============================================"
if npm deprecate "${FULL_PKG}@${VERSION}" "${MESSAGE}"; then
echo "✅ Successfully deprecated ${FULL_PKG}@${VERSION}"
else
echo "❌ Failed to deprecate ${FULL_PKG}@${VERSION}"
FAILED=$((FAILED + 1))
fi
echo ""
done
if [ "$FAILED" -gt 0 ]; then
echo "⚠️ ${FAILED} package(s) failed to deprecate."
exit 1
fi
echo "🎉 All packages deprecated successfully!"
notify-success:
needs: deprecate
if: success()
uses: ./.github/workflows/slack-notify.yml
with:
title: 'SDK Deprecation'
status: 'success'
version: ${{ inputs.version }}
secrets: inherit
notify-failure:
needs: deprecate
if: failure()
uses: ./.github/workflows/slack-notify.yml
with:
title: 'SDK Deprecation'
status: 'failure'
version: ${{ inputs.version }}
secrets: inherit