Skip to content

Commit c0c9b1e

Browse files
committed
chore(ci): test permissions to push
1 parent 6ce990c commit c0c9b1e

File tree

2 files changed

+97
-93
lines changed

2 files changed

+97
-93
lines changed

.github/workflows/publish.yml

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -67,56 +67,59 @@ jobs:
6767
echo "You must be a member of @supabase/admin or @supabase/client-libs."
6868
exit 1
6969
70-
# - uses: actions/checkout@v5
71-
# with:
72-
# fetch-depth: 0
73-
74-
# - uses: actions/setup-node@v4
75-
# with:
76-
# node-version: ${{ env.NODE_VERSION }}
77-
# cache: 'npm'
78-
# registry-url: 'https://registry.npmjs.org'
70+
- uses: actions/checkout@v5
71+
with:
72+
fetch-depth: 0
7973

80-
# # Ensure npm 11.5.1 or later is installed for trusted publishing support
81-
# - name: Update npm
82-
# run: npm install -g npm@latest
83-
# - name: Install dependencies
84-
# run: npm ci --legacy-peer-deps
85-
# - name: Configure git
86-
# run: |
87-
# git config --global user.name "supabase-releaser[bot]"
88-
# git config --global user.email "supabase-releaser[bot]@users.noreply.github.com"
74+
- uses: actions/setup-node@v4
75+
with:
76+
node-version: ${{ env.NODE_VERSION }}
77+
cache: 'npm'
78+
registry-url: 'https://registry.npmjs.org'
8979

90-
# - name: Validate input
91-
# run: |
92-
# VS="${{ github.event.inputs.version_specifier }}"
93-
# echo "Validating: $VS"
80+
# Ensure npm 11.5.1 or later is installed for trusted publishing support
81+
- name: Update npm
82+
run: npm install -g npm@latest
83+
- name: Install dependencies
84+
run: npm ci --legacy-peer-deps
85+
- name: Configure git
86+
run: |
87+
git config --global user.name "supabase-releaser[bot]"
88+
git config --global user.email "supabase-releaser[bot]@users.noreply.github.com"
9489
95-
# if [[ "$VS" =~ ^(patch|minor|major|prepatch|preminor|premajor|prerelease)$ ]]; then
96-
# echo "✔ bump keyword"
97-
# elif [[ "$VS" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
98-
# echo "✔ explicit version"
99-
# else
100-
# echo "❌ Invalid version_specifier: '$VS'"
101-
# echo " Use: patch|minor|major|pre*, or v1.2.3"
102-
# exit 1
103-
# fi
90+
- name: Validate input
91+
run: |
92+
VS="${{ github.event.inputs.version_specifier }}"
93+
echo "Validating: $VS"
10494
105-
# - name: Release
106-
# env:
107-
# NPM_CONFIG_PROVENANCE: true
108-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
109-
# RELEASE_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # used for tags
110-
# run: |
111-
# npm run release-stable -- --versionSpecifier "${{ github.event.inputs.version_specifier }}"
95+
if [[ "$VS" =~ ^(patch|minor|major|prepatch|preminor|premajor|prerelease)$ ]]; then
96+
echo "✔ bump keyword"
97+
elif [[ "$VS" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
98+
echo "✔ explicit version"
99+
else
100+
echo "❌ Invalid version_specifier: '$VS'"
101+
echo " Use: patch|minor|major|pre*, or v1.2.3"
102+
exit 1
103+
fi
104+
105+
- name: Set git remote to use App token
106+
run: git remote set-url origin https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/supabase/supabase-js.git
107+
108+
- name: Release
109+
env:
110+
NPM_CONFIG_PROVENANCE: true
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
RELEASE_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # used for tags
113+
run: |
114+
npm run release-stable -- --versionSpecifier "${{ github.event.inputs.version_specifier }}"
112115
113-
# - name: Summary
114-
# if: ${{ success() }}
115-
# run: |
116-
# echo "## ✅ Stable Release" >> $GITHUB_STEP_SUMMARY
117-
# echo "- **Version specifier:** \`${{ github.event.inputs.version_specifier }}\`" >> $GITHUB_STEP_SUMMARY
118-
# echo "- **Source commit:** HEAD of the checked-out branch" >> $GITHUB_STEP_SUMMARY
119-
# echo "- **Dist-tag:** \`latest\`" >> $GITHUB_STEP_SUMMARY
116+
- name: Summary
117+
if: ${{ success() }}
118+
run: |
119+
echo "## ✅ Stable Release" >> $GITHUB_STEP_SUMMARY
120+
echo "- **Version specifier:** \`${{ github.event.inputs.version_specifier }}\`" >> $GITHUB_STEP_SUMMARY
121+
echo "- **Source commit:** HEAD of the checked-out branch" >> $GITHUB_STEP_SUMMARY
122+
echo "- **Dist-tag:** \`latest\`" >> $GITHUB_STEP_SUMMARY
120123
121124
# docs-after-stable-release:
122125
# name: Generate Documentation

scripts/release-stable.ts

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
4040
}
4141

4242
;(async () => {
43-
const { workspaceVersion, projectsVersionData } = await releaseVersion({
44-
verbose: true,
45-
gitCommit: false,
46-
stageChanges: false,
47-
specifier: versionSpecifier,
48-
})
43+
// const { workspaceVersion, projectsVersionData } = await releaseVersion({
44+
// verbose: true,
45+
// gitCommit: false,
46+
// stageChanges: false,
47+
// specifier: versionSpecifier,
48+
// })
4949

5050
// Update version.ts files with the new versions
5151
console.log('\n📦 Updating version.ts files...')
52-
execSync('npx tsx scripts/update-version-files.ts', { stdio: 'inherit' })
52+
// execSync('npx tsx scripts/update-version-files.ts', { stdio: 'inherit' })
5353

5454
// Rebuild packages with correct versions
5555
console.log('\n🔨 Rebuilding packages with new versions...')
56-
execSync('npx nx run-many --target=build --all', { stdio: 'inherit' })
56+
// execSync('npx nx run-many --target=build --all', { stdio: 'inherit' })
5757
console.log('✅ Build complete\n')
5858

5959
// releaseChangelog should use the GitHub token with permission for tagging
@@ -71,64 +71,65 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
7171
const authHeader = `AUTHORIZATION: basic ${Buffer.from(`x-access-token:${process.env.RELEASE_GITHUB_TOKEN}`).toString('base64')}`
7272
execSync(`git config --local http.https://github.com/.extraheader "${authHeader}"`)
7373

74-
const result = await releaseChangelog({
75-
versionData: projectsVersionData,
76-
version: workspaceVersion,
77-
verbose: true,
78-
gitCommit: false,
79-
stageChanges: false,
80-
})
74+
// const result = await releaseChangelog({
75+
// versionData: projectsVersionData,
76+
// version: workspaceVersion,
77+
// verbose: true,
78+
// gitCommit: false,
79+
// stageChanges: false,
80+
// })
8181

8282
// npm publish with OIDC
8383
// not strictly necessary to restore the header but do it incase we require it later
8484
execSync(`git config --local http.https://github.com/.extraheader "${originalAuth}"`)
8585
// restore the GH token
8686
process.env.GITHUB_TOKEN = gh_token_bak
8787

88-
const publishResult = await releasePublish({
89-
registry: 'https://registry.npmjs.org/',
90-
access: 'public',
91-
tag: 'latest',
92-
verbose: true,
93-
})
88+
// const publishResult = await releasePublish({
89+
// registry: 'https://registry.npmjs.org/',
90+
// access: 'public',
91+
// tag: 'latest',
92+
// verbose: true,
93+
// })
9494

9595
// Publish gotrue-js as legacy mirror of auth-js
96-
console.log('\n📦 Publishing @supabase/gotrue-js (legacy mirror)...')
97-
try {
98-
execSync('npx tsx scripts/publish-gotrue-legacy.ts --tag=latest', { stdio: 'inherit' })
99-
} catch (error) {
100-
console.error('❌ Failed to publish gotrue-js legacy package:', error)
101-
// Don't fail the entire release if gotrue-js fails
102-
console.log('⚠️ Continuing with release despite gotrue-js publish failure')
103-
}
96+
// console.log('\n📦 Publishing @supabase/gotrue-js (legacy mirror)...')
97+
// try {
98+
// execSync('npx tsx scripts/publish-gotrue-legacy.ts --tag=latest', { stdio: 'inherit' })
99+
// } catch (error) {
100+
// console.error('❌ Failed to publish gotrue-js legacy package:', error)
101+
// // Don't fail the entire release if gotrue-js fails
102+
// console.log('⚠️ Continuing with release despite gotrue-js publish failure')
103+
// }
104104

105105
// ---- Create release branch + PR ----
106106
// switch back to the releaser GitHub token
107107
process.env.GITHUB_TOKEN = process.env.RELEASE_GITHUB_TOKEN
108-
const version = result.workspaceChangelog?.releaseVersion.rawVersion || workspaceVersion
108+
// const version = result.workspaceChangelog?.releaseVersion.rawVersion || workspaceVersion
109109

110110
// Validate version to prevent command injection
111111
// Version should match semver pattern or be a valid npm version specifier
112-
if (
113-
!version ||
114-
!/^(v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?|patch|minor|major|prepatch|preminor|premajor|prerelease)$/.test(
115-
version
116-
)
117-
) {
118-
console.error(`❌ Invalid version format: ${version}`)
119-
process.exit(1)
120-
}
121-
122-
const branchName = `release-${version}`
112+
// if (
113+
// !version ||
114+
// !/^(v?\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?|patch|minor|major|prepatch|preminor|premajor|prerelease)$/.test(
115+
// version
116+
// )
117+
// ) {
118+
// console.error(`❌ Invalid version format: ${version}`)
119+
// process.exit(1)
120+
// }
121+
122+
const branchName = `release-test}`
123123

124124
try {
125125
execSync(`git checkout -b ${branchName}`)
126-
execSync('git add CHANGELOG.md || true')
127-
execSync('git add packages/**/CHANGELOG.md || true')
126+
// create a small file and git add it
127+
execSync('touch test.txt')
128+
execSync('git add test.txt')
128129

129130
// Commit changes if any
130131
try {
131-
execSync(`git commit -m "chore(release): publish version ${version}"`)
132+
execSync(`git commit -m "chore(repo): test permissions"`)
132133
} catch {
133134
console.log('No changes to commit')
134135
}
@@ -137,18 +138,18 @@ if (!validSpecifiers.includes(versionSpecifier) && !isValidVersion) {
137138

138139
// Open PR using GitHub CLI
139140
execSync(
140-
`gh pr create --base master --head ${branchName} --title "chore(release): ${version}" --body "Automated release PR for ${version}"`,
141+
`gh pr create --base master --head ${branchName} --title "chore(repo): test permissions" --body "chore(repo): test permissions"`,
141142
{ stdio: 'inherit' }
142143
)
143144

144145
// Enable auto-merge
145146
execSync(`gh pr merge --auto --squash`, { stdio: 'inherit' })
146147

147-
execSync('git stash')
148-
console.log('✅ Stashed package.json changes')
148+
// execSync('git stash')
149+
// console.log('✅ Stashed package.json changes')
149150
} catch (err) {
150151
console.error('❌ Failed to push release branch or open PR', err)
151152
}
152153

153-
process.exit(Object.values(publishResult).every((r) => r.code === 0) ? 0 : 1)
154+
// process.exit(Object.values(publishResult).every((r) => r.code === 0) ? 0 : 1)
154155
})()

0 commit comments

Comments
 (0)