mirror of
https://github.com/supabase/setup-cli.git
synced 2026-04-05 09:12:15 +00:00
Expose installed Supabase CLI version via output (#170)
Expose Supabase CLI version via output
This commit is contained in:
@@ -6,6 +6,9 @@ inputs:
|
|||||||
description: Version of Supabase CLI to install
|
description: Version of Supabase CLI to install
|
||||||
required: false
|
required: false
|
||||||
default: 1.28.3
|
default: 1.28.3
|
||||||
|
outputs:
|
||||||
|
version:
|
||||||
|
description: Version of installed Supabase CLI
|
||||||
runs:
|
runs:
|
||||||
using: node16
|
using: node16
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as tc from '@actions/tool-cache'
|
import * as tc from '@actions/tool-cache'
|
||||||
import gte from 'semver/functions/gte'
|
import gte from 'semver/functions/gte'
|
||||||
import {getDownloadUrl} from './utils'
|
import {getDownloadUrl, determineInstalledVersion} from './utils'
|
||||||
|
|
||||||
export const CLI_CONFIG_REGISTRY = 'SUPABASE_INTERNAL_IMAGE_REGISTRY'
|
export const CLI_CONFIG_REGISTRY = 'SUPABASE_INTERNAL_IMAGE_REGISTRY'
|
||||||
|
|
||||||
@@ -20,6 +20,10 @@ async function run(): Promise<void> {
|
|||||||
// Expose the tool by adding it to the PATH
|
// Expose the tool by adding it to the PATH
|
||||||
core.addPath(pathToCLI)
|
core.addPath(pathToCLI)
|
||||||
|
|
||||||
|
// Expose installed tool version
|
||||||
|
const determinedVersion = await determineInstalledVersion()
|
||||||
|
core.setOutput('version', determinedVersion)
|
||||||
|
|
||||||
// Use GHCR mirror by default
|
// Use GHCR mirror by default
|
||||||
if (version.toLowerCase() === 'latest' || gte(version, '1.28.0')) {
|
if (version.toLowerCase() === 'latest' || gte(version, '1.28.0')) {
|
||||||
core.exportVariable(CLI_CONFIG_REGISTRY, 'ghcr.io')
|
core.exportVariable(CLI_CONFIG_REGISTRY, 'ghcr.io')
|
||||||
|
|||||||
15
src/utils.ts
15
src/utils.ts
@@ -1,5 +1,9 @@
|
|||||||
|
import {exec} from 'child_process'
|
||||||
import os from 'os'
|
import os from 'os'
|
||||||
import lt from 'semver/functions/lt'
|
import lt from 'semver/functions/lt'
|
||||||
|
import {promisify} from 'util'
|
||||||
|
|
||||||
|
const doExec = promisify(exec)
|
||||||
|
|
||||||
// arch in [arm, arm64, x64...] (https://nodejs.org/docs/latest-v16.x/api/os.html#osarch)
|
// arch in [arm, arm64, x64...] (https://nodejs.org/docs/latest-v16.x/api/os.html#osarch)
|
||||||
// return value in [amd64, arm64, arm]
|
// return value in [amd64, arm64, arm]
|
||||||
@@ -31,3 +35,14 @@ export const getDownloadUrl = async (version: string): Promise<string> => {
|
|||||||
}
|
}
|
||||||
return `https://github.com/supabase/cli/releases/download/v${version}/${filename}`
|
return `https://github.com/supabase/cli/releases/download/v${version}/${filename}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const determineInstalledVersion = async (): Promise<string> => {
|
||||||
|
const {stdout} = await doExec('supabase --version')
|
||||||
|
|
||||||
|
const version = stdout.trim()
|
||||||
|
if (!version) {
|
||||||
|
throw new Error('Could not determine installed Supabase CLI version')
|
||||||
|
}
|
||||||
|
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user