Skip to content

Update @supabase/supabase-js #14

Update @supabase/supabase-js

Update @supabase/supabase-js #14

name: Update @supabase/supabase-js
on:
workflow_dispatch:
inputs:
version:
description: "Version to update to"
required: true
type: string
source:
description: "Source of the update"
required: false
type: string
default: "manual"
permissions:
pull-requests: read
contents: read
jobs:
update-supabase-js:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-supabase-update-${{ inputs.version }}
cancel-in-progress: false
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ github.event.repository.default_branch }}
- name: Setup pnpm
uses: pnpm/action-setup@fc06bc1257f339d1d5d8b3a19a8cae5388b55320 # v5.0.0
with:
version: 9
- name: Setup Node.js
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: "20"
cache: "pnpm"
cache-dependency-path: website/pnpm-lock.yaml
- name: Update @supabase/supabase-js
working-directory: website
run: |
npm pkg set "dependencies.@supabase/supabase-js=${{ inputs.version }}"
pnpm install --lockfile-only --ignore-scripts
- name: Fetch release notes
env:
VERSION: ${{ inputs.version }}
GH_TOKEN: ${{ github.token }}
run: |
CURRENT_FULL=$(git show HEAD:website/package.json | jq -r '.dependencies["@supabase/supabase-js"] // ""' | grep -oP '[\d]+\.[\d]+\.[\d]+(-[\w.]+)?')
CURRENT_BASE=$(echo "$CURRENT_FULL" | grep -oP '[\d]+\.[\d]+\.[\d]+')
[[ "$CURRENT_FULL" == *"-"* ]] && INCLUDE_CURRENT=true || INCLUDE_CURRENT=false
[[ "$VERSION" == *"-"* ]] && STABLE_ONLY=false || STABLE_ONLY=true
RELEASES=$(gh api "repos/supabase/supabase-js/releases?per_page=100")
RELEASE_NOTES=$(echo "$RELEASES" | jq -r \
--arg current "v${CURRENT_BASE}" \
--arg new "v${VERSION}" \
--argjson stable_only "$STABLE_ONLY" \
--argjson include_current "$INCLUDE_CURRENT" \
'[.[] | select(.draft == false) | select(if $stable_only then .prerelease == false else true end)] |
(map(.tag_name) | index($new)) as $start |
(map(.tag_name) | index($current)) as $end |
($end | if . != null and $include_current then . + 1 else . end) as $end_adj |
if $start == null then ["Target version not found in last 100 releases."]
elif $end_adj != null and $start >= $end_adj then ["Downgrade — no release notes available."]
else [.[$start:$end_adj][] | "## " + .tag_name + "\n\n" + (.body // "No release notes.")]
end | .[]')
echo "RELEASE_NOTES<<EOF" >> "$GITHUB_ENV"
echo "$RELEASE_NOTES" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
- name: Generate token
id: app-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ secrets.GH_AUTOFIX_APP_ID }}
private-key: ${{ secrets.GH_AUTOFIX_PRIVATE_KEY }}
- name: Create pull request
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: "chore: update @supabase/supabase-js to v${{ inputs.version }}"
title: "chore: update @supabase/supabase-js to v${{ inputs.version }}"
body: |
This PR updates `@supabase/supabase-js` to v${{ inputs.version }}.
**Source**: ${{ inputs.source }}
---
## Release Notes
${{ env.RELEASE_NOTES }}
This PR was created automatically.
branch: "gha/auto-update-supabase-js-v${{ inputs.version }}"
base: ${{ github.event.repository.default_branch }}