From 2117484206de807ffddcea938795b56f027107a9 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 3 Aug 2022 23:04:20 +0800 Subject: [PATCH] Fix binary path --- .github/workflows/check-dist.yml | 6 +++--- .github/workflows/codeql-analysis.yml | 6 +++--- __tests__/main.test.ts | 6 +++--- src/main.ts | 9 ++++----- src/utils.ts | 10 ++-------- 5 files changed, 15 insertions(+), 22 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 385b5db..34970a7 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -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 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f39fafb..a0c7417 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -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 diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index aba41d0..08a8f46 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -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/' ) }) diff --git a/src/main.ts b/src/main.ts index f991c84..19387e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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 { try { @@ -9,14 +8,14 @@ async function run(): Promise { 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) } diff --git a/src/utils.ts b/src/utils.ts index 69c432d..093fb53 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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 }