@@ -10,181 +10,70 @@ permissions:
1010 contents : read
1111
1212jobs :
13- release_please :
13+ release :
1414 runs-on : ubuntu-latest
1515 permissions :
16- id-token : write
1716 contents : write
1817 pull-requests : write
18+ id-token : write
1919 steps :
2020 - uses : googleapis/release-please-action@v4
2121 id : release
22- with :
23- release-type : go
24- target-branch : ${{ github.ref_name }}
2522
2623 - uses : actions/checkout@v4
27- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
2824 with :
2925 fetch-depth : 0
3026
31- - if : ${{ steps.release.outputs }}
32- id : versions
33- run : |
34- set -ex
35-
36- RELEASE_CANDIDATE=true
37- NOT_RELEASE_CANDIDATE='${{ steps.release.outputs.release_created }}'
38- if [ "$NOT_RELEASE_CANDIDATE" == "true" ]
39- then
40- RELEASE_CANDIDATE=false
41- fi
42-
43- MAIN_RELEASE_VERSION=x
44- RELEASE_VERSION=y
45-
46- if [ "$RELEASE_CANDIDATE" == "true" ]
47- then
48- # Release please doesn't tell you the candidate version when it
49- # creates the PR, so we have to take it from the title.
50- MAIN_RELEASE_VERSION=$(node -e "console.log('${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).title }}'.split(' ').reverse().find(x => x.match(/[0-9]+[.][0-9]+[.][0-9]+/)))")
51-
52- # Use git describe tags to identify the number of commits the branch
53- # is ahead of the most recent non-release-candidate tag, which is
54- # part of the rc.<commits> value.
55- RELEASE_VERSION=$MAIN_RELEASE_VERSION-rc.$(node -e "console.log('$(git describe --tags --exclude rc*)'.split('-')[1])")
56-
57- # release-please only ignores releases that have a form like [A-Z0-9]<version>, so prefixing with rc<version>
58- RELEASE_NAME="rc$RELEASE_VERSION"
59- else
60- MAIN_RELEASE_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
61- RELEASE_VERSION="$MAIN_RELEASE_VERSION"
62- RELEASE_NAME="v$RELEASE_VERSION"
63- fi
64-
65- echo "MAIN_RELEASE_VERSION=${MAIN_RELEASE_VERSION}" >> "${GITHUB_ENV}"
66- echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_ENV}"
67- echo "RELEASE_CANDIDATE=${RELEASE_CANDIDATE}" >> "${GITHUB_ENV}"
68- echo "RELEASE_NAME=${RELEASE_NAME}" >> "${GITHUB_ENV}"
69-
70- echo "MAIN_RELEASE_VERSION=${MAIN_RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
71- echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
72- echo "RELEASE_CANDIDATE=${RELEASE_CANDIDATE}" >> "${GITHUB_OUTPUT}"
73- echo "RELEASE_NAME=${RELEASE_NAME}" >> "${GITHUB_OUTPUT}"
74-
7527 - uses : actions/setup-node@v4
76- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
7728 with :
78- node-version : 20
29+ node-version : 22
30+ registry-url : " https://registry.npmjs.org"
7931
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
32+ - run : npm install -g npm@latest
8333
84- - name : Build release artifacts
85- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
34+ - name : Determine version
35+ id : version
8636 run : |
87- set -ex
88-
89- echo "export const VERSION = '$RELEASE_VERSION';" > src/version.ts
90-
91- npm ci
92- npm run build
93-
94- for f in package.json package-lock.json
95- do
96- sed -i 's|"version": "0.0.0",|"version": "'"$RELEASE_VERSION"'",|g' "$f"
97- done
98-
99- DIST_TAG=patched
100- if [ "$RELEASE_CANDIDATE" == "true" ]
101- then
102- DIST_TAG=rc
103- elif [ "$GITHUB_REF" == "refs/heads/main" ] || [ "$GITHUB_REF" == "refs/heads/master" ]
104- then
105- # This is the main branch and it's not a prerelease, so the dist-tag should be `latest`.
106- DIST_TAG=latest
107- elif [[ "$GITHUB_REF" == "refs/heads/release/"* ]]
108- then
109- # This is a release branch. We need to determine if this release
110- # branch is the _latest_ release branch. If yes, use
111- # DIST_TAG=latest. Make sure checkout action runs with
112- # fetch-depth: 0!
113-
114- LATEST_BRANCH=$(git branch -al origin/release/* --sort=-v:refname | head -n 1 | tr -d "* \t")
115- REF_AS_REMOTE_BRANCH=$(echo "$GITHUB_REF" | sed "s|refs/heads/|remotes/origin/|g")
116-
117- if [ "$LATEST_BRANCH" == "$REF_AS_REMOTE_BRANCH" ]
118- then
119- DIST_TAG=latest
37+ if [ "${{ steps.release.outputs.release_created }}" == "true" ]; then
38+ VERSION="${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}"
39+ TAG="latest"
40+
41+ # For release branches, check if this is the latest release branch
42+ if [[ "$GITHUB_REF" == refs/heads/release/* ]]; then
43+ LATEST_BRANCH=$(git branch -r --list 'origin/release/*' --sort=-v:refname | head -n 1 | tr -d ' ')
44+ CURRENT_BRANCH="origin/${GITHUB_REF#refs/heads/}"
45+ if [ "$LATEST_BRANCH" != "$CURRENT_BRANCH" ]; then
46+ TAG="patched"
47+ fi
48+ fi
49+ else
50+ # RC only for main branch
51+ if [[ "$GITHUB_REF" != refs/heads/main ]]; then
52+ echo "skip=true" >> $GITHUB_OUTPUT
53+ exit 0
12054 fi
121- fi
122-
123- echo "Publishing @supabase/ssr now..."
124-
125- npm publish --provenance --tag "$DIST_TAG"
126-
127- # Also publish under deprecated auth-helpers names for backward compatibility
128- # This helps users still using the old packages (especially due to LLM recommendations)
129- echo "Publishing under legacy auth-helpers names..."
130-
131- # Publish as @supabase/auth-helpers-nextjs
132- echo "Publishing as @supabase/auth-helpers-nextjs..."
133- sed -i 's|"name": "@supabase/ssr"|"name": "@supabase/auth-helpers-nextjs"|g' package.json
134- npm publish --provenance --tag "$DIST_TAG"
135-
136- # Publish as @supabase/auth-helpers-react
137- echo "Publishing as @supabase/auth-helpers-react..."
138- sed -i 's|"name": "@supabase/auth-helpers-nextjs"|"name": "@supabase/auth-helpers-react"|g' package.json
139- npm publish --provenance --tag "$DIST_TAG"
140-
141- # Publish as @supabase/auth-helpers-remix
142- echo "Publishing as @supabase/auth-helpers-remix..."
143- sed -i 's|"name": "@supabase/auth-helpers-react"|"name": "@supabase/auth-helpers-remix"|g' package.json
144- npm publish --provenance --tag "$DIST_TAG"
145-
146- # Publish as @supabase/auth-helpers-sveltekit
147- echo "Publishing as @supabase/auth-helpers-sveltekit..."
148- sed -i 's|"name": "@supabase/auth-helpers-remix"|"name": "@supabase/auth-helpers-sveltekit"|g' package.json
149- npm publish --provenance --tag "$DIST_TAG"
15055
151- # Restore original package name for consistency
152- sed -i 's|"name": "@supabase/auth-helpers-sveltekit"|"name": "@supabase/ssr"|g' package.json
56+ # RC version from git describe, bump minor
57+ DESCRIBE=$(git describe --tags --always)
58+ BASE=$(echo "$DESCRIBE" | sed 's/^v//' | cut -d'-' -f1)
59+ MAJOR=$(echo "$BASE" | cut -d'.' -f1)
60+ MINOR=$(echo "$BASE" | cut -d'.' -f2)
61+ COMMITS=$(echo "$DESCRIBE" | cut -d'-' -f2)
62+ NEXT_MINOR=$((MINOR + 1))
63+ VERSION="${MAJOR}.${NEXT_MINOR}.0-rc.${COMMITS}"
64+ TAG="rc"
65+ fi
66+ echo "version=$VERSION" >> $GITHUB_OUTPUT
67+ echo "tag=$TAG" >> $GITHUB_OUTPUT
15368
154- - name : Create GitHub release and branches
155- if : ${{ steps.release .outputs.release_created == 'true' || steps.release.outputs.prs_created = = 'true' }}
69+ - name : Build
70+ if : ${{ steps.version .outputs.skip ! = 'true' }}
15671 run : |
157- set -ex
158-
159- if [ "$RELEASE_CANDIDATE" == "true" ]
160- then
161- PR_NUMBER='${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).number }}'
162-
163- GH_TOKEN='${{ github.token }}' gh release \
164- create $RELEASE_NAME \
165- --title "v$RELEASE_VERSION" \
166- --prerelease \
167- -n "This is a release candidate. See release-please PR #$PR_NUMBER for context."
168-
169- GH_TOKEN='${{ github.token }}' gh pr comment "$PR_NUMBER" \
170- -b "Release candidate [v$RELEASE_VERSION](https://github.com/supabase/ssr/releases/tag/$RELEASE_NAME) published."
171- else
172- if [ "$GITHUB_REF" == "refs/heads/main" ] || [ "$GITHUB_REF" == "refs/heads/master" ]
173- then
174- IS_PATCH_ZERO=$(node -e "console.log('$RELEASE_VERSION'.endsWith('.0'))")
175-
176- if [ "$IS_PATCH_ZERO" == "true" ]
177- then
178- # Only create release branch if patch version is 0, as this
179- # means that the release can be patched in the future.
72+ echo "export const VERSION = '${{ steps.version.outputs.version }}';" > src/version.ts
73+ npm ci
74+ npm run build
75+ npm version ${{ steps.version.outputs.version }} --no-git-tag-version
18076
181- GH_TOKEN='${{ github.token }}' gh api \
182- --method POST \
183- -H "Accept: application/vnd.github+json" \
184- -H "X-GitHub-Api-Version: 2022-11-28" \
185- /repos/supabase/ssr/git/refs \
186- -f "ref=refs/heads/release/${RELEASE_VERSION}" \
187- -f "sha=$GITHUB_SHA"
188- fi
189- fi
190- fi
77+ - name : Publish
78+ if : ${{ steps.version.outputs.skip != 'true' }}
79+ run : npm publish --provenance --tag ${{ steps.version.outputs.tag }}
0 commit comments