44 push :
55 branches :
66 - main
7- - release/*
87
98permissions :
109 contents : read
1110
1211jobs :
13- release_please :
12+ release :
1413 runs-on : ubuntu-latest
1514 permissions :
16- id-token : write
1715 contents : write
1816 pull-requests : write
17+ id-token : write
1918 steps :
2019 - uses : googleapis/release-please-action@v4
2120 id : release
22- with :
23- release-type : go
24- target-branch : ${{ github.ref_name }}
2521
2622 - uses : actions/checkout@v4
27- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
2823 with :
2924 fetch-depth : 0
3025
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-
7526 - uses : actions/setup-node@v4
76- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
7727 with :
78- node-version : 20
28+ node-version : 22
29+ registry-url : ' https://registry.npmjs.org'
7930
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
31+ - run : npm install -g npm@latest
8332
84- - name : Build release artifacts
85- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
33+ - name : Determine version
34+ id : version
8635 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
120- fi
36+ if [ "${{ steps.release.outputs.release_created }}" == "true" ]; then
37+ VERSION="${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}"
38+ TAG="latest"
39+ else
40+ # RC version from git describe, bump minor
41+ DESCRIBE=$(git describe --tags --always)
42+ BASE=$(echo "$DESCRIBE" | sed 's/^v//' | cut -d'-' -f1)
43+ MAJOR=$(echo "$BASE" | cut -d'.' -f1)
44+ MINOR=$(echo "$BASE" | cut -d'.' -f2)
45+ COMMITS=$(echo "$DESCRIBE" | cut -d'-' -f2)
46+ NEXT_MINOR=$((MINOR + 1))
47+ VERSION="${MAJOR}.${NEXT_MINOR}.0-rc.${COMMITS}"
48+ TAG="rc"
12149 fi
50+ echo "version=$VERSION" >> $GITHUB_OUTPUT
51+ echo "tag=$TAG" >> $GITHUB_OUTPUT
12252
123- npm publish --provenance --tag "$DIST_TAG"
124-
125- - name : Create GitHub release and branches
126- if : ${{ steps.release.outputs.release_created == 'true' || steps.release.outputs.prs_created == 'true' }}
53+ - name : Build
12754 run : |
128- set -ex
129-
130- if [ "$RELEASE_CANDIDATE" == "true" ]
131- then
132- PR_NUMBER='${{ steps.release.outputs.pr && fromJSON(steps.release.outputs.pr).number }}'
133-
134- GH_TOKEN='${{ github.token }}' gh release \
135- create $RELEASE_NAME \
136- --title "v$RELEASE_VERSION" \
137- --prerelease \
138- -n "This is a release candidate. See release-please PR #$PR_NUMBER for context."
139-
140- GH_TOKEN='${{ github.token }}' gh pr comment "$PR_NUMBER" \
141- -b "Release candidate [v$RELEASE_VERSION](https://github.com/supabase/ssr/releases/tag/$RELEASE_NAME) published."
142- else
143- if [ "$GITHUB_REF" == "refs/heads/main" ] || [ "$GITHUB_REF" == "refs/heads/master" ]
144- then
145- IS_PATCH_ZERO=$(node -e "console.log('$RELEASE_VERSION'.endsWith('.0'))")
146-
147- if [ "$IS_PATCH_ZERO" == "true" ]
148- then
149- # Only create release branch if patch version is 0, as this
150- # means that the release can be patched in the future.
55+ echo "export const VERSION = '${{ steps.version.outputs.version }}';" > src/version.ts
56+ npm ci
57+ npm run build
58+ npm version ${{ steps.version.outputs.version }} --no-git-tag-version
15159
152- GH_TOKEN='${{ github.token }}' gh api \
153- --method POST \
154- -H "Accept: application/vnd.github+json" \
155- -H "X-GitHub-Api-Version: 2022-11-28" \
156- /repos/supabase/ssr/git/refs \
157- -f "ref=refs/heads/release/${RELEASE_VERSION}" \
158- -f "sha=$GITHUB_SHA"
159- fi
160- fi
161- fi
60+ - name : Publish
61+ run : npm publish --provenance --tag ${{ steps.version.outputs.tag }}
0 commit comments