mirror of
https://github.com/supabase/setup-cli.git
synced 2026-02-09 03:45:28 +00:00
Fix binary path
This commit is contained in:
6
.github/workflows/check-dist.yml
vendored
6
.github/workflows/check-dist.yml
vendored
@@ -21,10 +21,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set Node.js 16.x
|
- name: Set Node.js 16.x
|
||||||
uses: actions/setup-node@v2.5.1
|
uses: actions/setup-node@v3.4.1
|
||||||
with:
|
with:
|
||||||
node-version: 16.x
|
node-version: 16.x
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ jobs:
|
|||||||
id: diff
|
id: diff
|
||||||
|
|
||||||
# If index.js was different than expected, upload the expected version as an artifact
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v3
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
|
|||||||
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -42,7 +42,7 @@ jobs:
|
|||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v1
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
source-root: src
|
source-root: src
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v1
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 https://git.io/JvXDl
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -68,4 +68,4 @@ jobs:
|
|||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {getDownloadObject} from '../src/utils'
|
import {getDownloadUrl} from '../src/utils'
|
||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import * as process from 'process'
|
import * as process from 'process'
|
||||||
import * as cp from 'child_process'
|
import * as cp from 'child_process'
|
||||||
@@ -6,8 +6,8 @@ import * as path from 'path'
|
|||||||
import {expect, test} from '@jest/globals'
|
import {expect, test} from '@jest/globals'
|
||||||
|
|
||||||
test('returns download path to binary', async () => {
|
test('returns download path to binary', async () => {
|
||||||
const link = getDownloadObject('0.1.0')
|
const url = getDownloadUrl('0.1.0')
|
||||||
expect(link.url).toContain(
|
expect(url).toContain(
|
||||||
'https://github.com/supabase/cli/releases/download/v0.1.0/'
|
'https://github.com/supabase/cli/releases/download/v0.1.0/'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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 * as path from 'path'
|
import {getDownloadUrl} from './utils'
|
||||||
import {getDownloadObject} from './utils'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -9,14 +8,14 @@ async function run(): Promise<void> {
|
|||||||
const version = core.getInput('version')
|
const version = core.getInput('version')
|
||||||
|
|
||||||
// Download the specific version of the tool, e.g. as a tarball/zipball
|
// Download the specific version of the tool, e.g. as a tarball/zipball
|
||||||
const download = getDownloadObject(version)
|
const download = getDownloadUrl(version)
|
||||||
const pathToTarball = await tc.downloadTool(download.url)
|
const pathToTarball = await tc.downloadTool(download)
|
||||||
|
|
||||||
// Extract the tarball/zipball onto host runner
|
// Extract the tarball/zipball onto host runner
|
||||||
const pathToCLI = await tc.extractTar(pathToTarball)
|
const pathToCLI = await tc.extractTar(pathToTarball)
|
||||||
|
|
||||||
// Expose the tool by adding it to the PATH
|
// Expose the tool by adding it to the PATH
|
||||||
core.addPath(path.join(pathToCLI, download.binPath))
|
core.addPath(pathToCLI)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) core.setFailed(error.message)
|
if (error instanceof Error) core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/utils.ts
10
src/utils.ts
@@ -19,16 +19,10 @@ const mapOS = (platform: string): string => {
|
|||||||
return mappings[platform] || platform
|
return mappings[platform] || platform
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDownloadObject = (
|
export const getDownloadUrl = (version: string): string => {
|
||||||
version: string
|
|
||||||
): {url: string; binPath: string} => {
|
|
||||||
const platform = mapOS(os.platform())
|
const platform = mapOS(os.platform())
|
||||||
const arch = mapArch(os.arch())
|
const arch = mapArch(os.arch())
|
||||||
const filename = `supabase_${version}_${platform}_${arch}`
|
const filename = `supabase_${version}_${platform}_${arch}`
|
||||||
const binPath = platform === 'windows' ? 'bin' : path.join(filename, 'bin')
|
|
||||||
const url = `https://github.com/supabase/cli/releases/download/v${version}/${filename}.tar.gz`
|
const url = `https://github.com/supabase/cli/releases/download/v${version}/${filename}.tar.gz`
|
||||||
return {
|
return url
|
||||||
url,
|
|
||||||
binPath
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user