Fix binary path

This commit is contained in:
Qiao Han
2022-08-03 23:04:20 +08:00
parent 78c4398270
commit 2117484206
5 changed files with 15 additions and 22 deletions

View File

@@ -21,10 +21,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set Node.js 16.x
uses: actions/setup-node@v2.5.1
uses: actions/setup-node@v3.4.1
with:
node-version: 16.x
@@ -46,7 +46,7 @@ jobs:
id: diff
# 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' }}
with:
name: dist

View File

@@ -42,7 +42,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
source-root: src
@@ -54,7 +54,7 @@ jobs:
# 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)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@@ -1,4 +1,4 @@
import {getDownloadObject} from '../src/utils'
import {getDownloadUrl} from '../src/utils'
import * as os from 'os'
import * as process from 'process'
import * as cp from 'child_process'
@@ -6,8 +6,8 @@ import * as path from 'path'
import {expect, test} from '@jest/globals'
test('returns download path to binary', async () => {
const link = getDownloadObject('0.1.0')
expect(link.url).toContain(
const url = getDownloadUrl('0.1.0')
expect(url).toContain(
'https://github.com/supabase/cli/releases/download/v0.1.0/'
)
})

View File

@@ -1,7 +1,6 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import * as path from 'path'
import {getDownloadObject} from './utils'
import {getDownloadUrl} from './utils'
async function run(): Promise<void> {
try {
@@ -9,14 +8,14 @@ async function run(): Promise<void> {
const version = core.getInput('version')
// Download the specific version of the tool, e.g. as a tarball/zipball
const download = getDownloadObject(version)
const pathToTarball = await tc.downloadTool(download.url)
const download = getDownloadUrl(version)
const pathToTarball = await tc.downloadTool(download)
// Extract the tarball/zipball onto host runner
const pathToCLI = await tc.extractTar(pathToTarball)
// Expose the tool by adding it to the PATH
core.addPath(path.join(pathToCLI, download.binPath))
core.addPath(pathToCLI)
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
}

View File

@@ -19,16 +19,10 @@ const mapOS = (platform: string): string => {
return mappings[platform] || platform
}
export const getDownloadObject = (
version: string
): {url: string; binPath: string} => {
export const getDownloadUrl = (version: string): string => {
const platform = mapOS(os.platform())
const arch = mapArch(os.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`
return {
url,
binPath
}
return url
}