Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CodeQL

on:
pull_request:
push:
branches:
- main
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: ${{ github.workspace }}
VALIDATE_ALL_CODEBASE: true
VALIDATE_BIOME_FORMAT: false
VALIDATE_JAVASCRIPT_ES: false
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false
VALIDATE_TYPESCRIPT_ES: false
VALIDATE_JSON: false
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
VALIDATE_TYPESCRIPT_STANDARD: false
1 change: 1 addition & 0 deletions .github/workflows/start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
- uses: ./
with:
version: ${{ matrix.version }}
github-token: ${{ github.token }}
- run: supabase init
- run:
sed -i -E "s|^(major_version) .*|\1 = ${{ matrix.pg_major }}|"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
- uses: ./
with:
version: ${{ matrix.version }}
github-token: ${{ github.token }}
- run: supabase -h

check:
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/core.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "@actions/core"
version: 1.11.1
version: 3.0.1
type: npm
summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/exec.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "@actions/exec"
version: 1.1.1
version: 3.0.0
type: npm
summary: Actions exec lib
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/http-client.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "@actions/http-client"
version: 2.2.3
version: 4.0.1
type: npm
summary: Actions Http Client
homepage: https://github.com/actions/toolkit/tree/main/packages/http-client
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/io.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "@actions/io"
version: 1.1.3
version: 3.0.2
type: npm
summary: Actions io lib
homepage: https://github.com/actions/toolkit/tree/main/packages/io
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/tool-cache.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: "@actions/tool-cache"
version: 2.0.2
version: 4.0.0
type: npm
summary: Actions tool-cache lib
homepage: https://github.com/actions/toolkit/tree/main/packages/tool-cache
Expand Down
30 changes: 0 additions & 30 deletions .licenses/npm/@fastify/busboy.dep.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .licenses/npm/semver-7.7.2.dep.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: semver
version: 6.3.1
version: 7.8.0
type: npm
summary: The semantic version parser used by npm.
homepage:
Expand Down
2 changes: 1 addition & 1 deletion .licenses/npm/undici.dep.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: undici
version: 5.29.0
version: 6.25.0
type: npm
summary: An HTTP/1.1 client, written from scratch for Node.js
homepage: https://undici.nodejs.org
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ steps:
- uses: supabase/setup-cli@v1
with:
version: latest
github-token: ${{ github.token }}
- run: supabase init
- run: supabase db start
```
Expand All @@ -55,9 +56,10 @@ on Windows and macOS runners.

The actions supports the following inputs:

| Name | Type | Description | Default | Required |
| --------- | ------ | ---------------------------------- | -------- | -------- |
| `version` | String | Supabase CLI version (or `latest`) | `2.20.3` | false |
| Name | Type | Description | Default | Required |
| -------------- | ------ | -------------------------------------------------------------------------- | -------- | -------- |
| `version` | String | Supabase CLI version (or `latest`) | `2.20.3` | false |
| `github-token` | String | GitHub token used to resolve `latest` without unauthenticated API limiting | | false |

## Advanced Usage

Expand Down Expand Up @@ -135,8 +137,8 @@ need to perform some initial setup steps before you can develop your action.

## Publish to a distribution branch

Actions are run from this GitHub repository so we will checkin the packed `dist`
folder.
Actions are run from this GitHub repository so we will check in the packed
`dist` folder.

1. Create a new GitHub release
2. Rebase `v1` branch on `main`
Expand All @@ -155,6 +157,7 @@ repository (see [test.yml](.github/workflows/test.yml))
uses: ./
with:
version: latest
github-token: ${{ github.token }}
```

See the [actions tab](https://github.com/supabase/setup-cli/actions) for runs of
Expand Down
68 changes: 67 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDownloadArchive, getDownloadUrl } from '../src/utils'
import { getCliPath, getDownloadArchive, getDownloadUrl } from '../src/utils'
import { CLI_CONFIG_REGISTRY } from '../src/main'
import * as os from 'os'
import * as process from 'process'
Expand Down Expand Up @@ -47,6 +47,48 @@ test('gets download url to latest version', async () => {
expect(url).toMatch(/\.tar\.gz$|\.zip$/)
})

test('authenticates latest version lookup when a GitHub token is provided', async () => {
const fetchMock = jest.spyOn(globalThis, 'fetch').mockResolvedValue(
new Response(JSON.stringify({ tag_name: 'v2.99.0' }), {
status: 200,
statusText: 'OK'
})
)

await getDownloadUrl('latest', 'github-token')

expect(fetchMock).toHaveBeenCalledWith(
'https://api.github.com/repos/supabase/cli/releases/latest',
expect.objectContaining({
headers: expect.objectContaining({
Accept: 'application/vnd.github+json',
Authorization: 'Bearer github-token',
'X-GitHub-Api-Version': '2022-11-28'
})
})
)
})

test('omits authorization from latest version lookup without a GitHub token', async () => {
const fetchMock = jest.spyOn(globalThis, 'fetch').mockResolvedValue(
new Response(JSON.stringify({ tag_name: 'v2.99.0' }), {
status: 200,
statusText: 'OK'
})
)

await getDownloadUrl('latest')

expect(fetchMock).toHaveBeenCalledWith(
'https://api.github.com/repos/supabase/cli/releases/latest',
expect.objectContaining({
headers: expect.not.objectContaining({
Authorization: expect.any(String)
})
})
)
})

test('gets versioned archive url to binary from Supabase CLI v2.99.0', async () => {
const archive = await getDownloadArchive('2.99.0', 'linux', 'x64')

Expand All @@ -56,6 +98,30 @@ test('gets versioned archive url to binary from Supabase CLI v2.99.0', async ()
})
})

test('gets apk archive url on Linux musl from Supabase CLI v2.99.0', async () => {
const archive = await getDownloadArchive('2.99.0', 'linux', 'x64', true)

expect(archive).toEqual({
url: 'https://github.com/supabase/cli/releases/download/v2.99.0/supabase_2.99.0_linux_amd64.apk',
format: 'apk'
})
})

test('keeps tar archives before Supabase CLI v2.99.0 on Linux musl', async () => {
const archive = await getDownloadArchive('2.98.2', 'linux', 'x64', true)

expect(archive).toEqual({
url: 'https://github.com/supabase/cli/releases/download/v2.98.2/supabase_linux_amd64.tar.gz',
format: 'tar'
})
})

test('uses usr/bin as the CLI path for apk archives', () => {
expect(getCliPath('/tmp/extracted', 'apk')).toBe('/tmp/extracted/usr/bin')
expect(getCliPath('/tmp/extracted', 'tar')).toBe('/tmp/extracted')
expect(getCliPath('/tmp/extracted', 'zip')).toBe('/tmp/extracted')
})

test('gets versioned zip archive url on Windows from Supabase CLI v2.99.0', async () => {
const archive = await getDownloadArchive('2.99.0', 'win32', 'x64')

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ inputs:
description: Version of Supabase CLI to install
required: false
default: 2.20.3
github-token:
description:
GitHub token used to resolve the latest Supabase CLI release without
hitting unauthenticated API limits.
required: false
outputs:
version:
description: Version of installed Supabase CLI
Expand Down
Loading
Loading