From 39cbf44fc1f24dd34d420033092c94411430e35c Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 4 Aug 2022 00:15:17 +0800 Subject: [PATCH] Upgrade to node 18 --- .github/workflows/check-dist.yml | 8 +-- .github/workflows/codeql-analysis.yml | 2 +- README.md | 98 ++++++++++++--------------- __tests__/main.test.ts | 2 +- action.yml | 4 +- package-lock.json | 14 ++-- package.json | 2 +- 7 files changed, 58 insertions(+), 72 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 34970a7..fea7e0b 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -23,13 +23,11 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set Node.js 16.x - uses: actions/setup-node@v3.4.1 + - uses: actions/setup-node@v3.4.1 with: - node-version: 16.x + node-version: 18.x - - name: Install dependencies - run: npm ci + - run: npm ci - name: Rebuild the dist/ directory run: | diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a0c7417..90b0615 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: 'CodeQL' on: push: diff --git a/README.md b/README.md index fac1dd6..91314bc 100644 --- a/README.md +++ b/README.md @@ -1,90 +1,82 @@ -

- typescript-action status -

+# :gear: Supabase CLI Action -# Create a JavaScript Action using TypeScript +![](https://github.com/supabase/setup-cli/workflows/build-test/badge.svg) +![](https://github.com/supabase/setup-cli/workflows/CodeQL/badge.svg) -Use this template to bootstrap the creation of a TypeScript action.:rocket: +## About -This template includes compilation support, tests, a validation workflow, publishing, and versioning guidance. +This action sets up the Supabase CLI, [`supabase`](https://github.com/supabase/cli), on GitHub's hosted Actions runners. -If you are new, there's also a simpler introduction. See the [Hello World JavaScript Action](https://github.com/actions/hello-world-javascript-action) +This action can be run on `ubuntu-latest`, `windows-latest`, and `macos-latest` GitHub Actions runners, and will install and expose a specified version of the `supabase` CLI on the runner environment. -## Create an action from this template +## Usage -Click the `Use this Template` and provide the new repo details for your action +Setup the `supabase` CLI: -## Code in Main +```yaml +steps: + - uses: supabase/setup-cli@v1 +``` -> First, you'll need to have a reasonably modern version of `node` handy. This won't work with versions older than 9, for instance. +A specific version of the `supabase` CLI can be installed: + +```yaml +steps: + - uses: supabase/setup-cli@v1 + with: + version: 0.32.1 +``` + +## Inputs + +The actions supports the following inputs: + +- `version`: The version of `supabase` to install, defaulting to `0.32.1` + +## Develop + +> Requires `node >= 16` + +Install the dependencies -Install the dependencies ```bash $ npm install ``` Build the typescript and package it for distribution + ```bash $ npm run build && npm run package ``` -Run the tests :heavy_check_mark: +Run the tests :heavy_check_mark: + ```bash $ npm test - PASS ./index.test.js - ✓ throws invalid number (3ms) - ✓ wait 500 ms (504ms) - ✓ test runs (95ms) + PASS __tests__/main.test.ts + ✓ gets download url to binary (3 ms) + ✓ test runs (891 ms) ... ``` -## Change action.yml - -The action.yml defines the inputs and output for your action. - -Update the action.yml with your name, description, inputs and outputs for your action. - -See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions) - -## Change the Code - -Most toolkit and CI/CD operations involve async operations so the action is run in an async function. - -```javascript -import * as core from '@actions/core'; -... - -async function run() { - try { - ... - } - catch (error) { - core.setFailed(error.message); - } -} - -run() -``` - -See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages. - ## Publish to a distribution branch -Actions are run from GitHub repos so we will checkin the packed dist folder. +Actions are run from GitHub repos so we will checkin the packed dist folder. Then run [ncc](https://github.com/zeit/ncc) and push the results: + ```bash $ npm run package $ git add dist -$ git commit -a -m "prod dependencies" +$ git commit -a -m "Update dependencies" $ git push origin releases/v1 ``` Note: We recommend using the `--license` option for ncc, which will create a license file for all of the production node modules used in your project. -Your action is now published! :rocket: +Your action is now published! :rocket: See the [versioning documentation](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) @@ -95,11 +87,7 @@ You can now validate the action by referencing `./` in a workflow in your repo ( ```yaml uses: ./ with: - milliseconds: 1000 + version: 0.32.1 ``` See the [actions tab](https://github.com/actions/typescript-action/actions) for runs of this action! :rocket: - -## Usage: - -After testing you can [create a v1 tag](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md) to reference the stable and latest V1 action diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 08a8f46..b74ffa2 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -5,7 +5,7 @@ import * as cp from 'child_process' import * as path from 'path' import {expect, test} from '@jest/globals' -test('returns download path to binary', async () => { +test('gets download url to binary', async () => { const url = getDownloadUrl('0.1.0') expect(url).toContain( 'https://github.com/supabase/cli/releases/download/v0.1.0/' diff --git a/action.yml b/action.yml index fd88f9f..87369f1 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: setup-cli +name: Supabase CLI Action description: Setup Supabase CLI, supabase, on GitHub Actions runners author: Supabase inputs: @@ -7,5 +7,5 @@ inputs: required: false default: 0.32.1 runs: - using: node16 + using: node18 main: dist/index.js diff --git a/package-lock.json b/package-lock.json index ab2b198..1c87e5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@actions/tool-cache": "^2.0.1" }, "devDependencies": { - "@types/node": "^16.11.47", + "@types/node": "^18.6.3", "@typescript-eslint/parser": "^5.32.0", "@vercel/ncc": "^0.34.0", "eslint": "^8.0.1", @@ -1551,9 +1551,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "16.11.47", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.47.tgz", - "integrity": "sha512-fpP+jk2zJ4VW66+wAMFoBJlx1bxmBKx4DUFf68UHgdGCOuyUTDlLWqsaNPJh7xhNDykyJ9eIzAygilP/4WoN8g==", + "version": "18.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz", + "integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==", "dev": true }, "node_modules/@types/prettier": { @@ -7819,9 +7819,9 @@ "dev": true }, "@types/node": { - "version": "16.11.47", - "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.47.tgz", - "integrity": "sha512-fpP+jk2zJ4VW66+wAMFoBJlx1bxmBKx4DUFf68UHgdGCOuyUTDlLWqsaNPJh7xhNDykyJ9eIzAygilP/4WoN8g==", + "version": "18.6.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.6.3.tgz", + "integrity": "sha512-6qKpDtoaYLM+5+AFChLhHermMQxc3TOEFIDzrZLPRGHPrLEwqFkkT5Kx3ju05g6X7uDPazz3jHbKPX0KzCjntg==", "dev": true }, "@types/prettier": { diff --git a/package.json b/package.json index fcb65ba..240e155 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@actions/tool-cache": "^2.0.1" }, "devDependencies": { - "@types/node": "^16.11.47", + "@types/node": "^18.6.3", "@typescript-eslint/parser": "^5.32.0", "@vercel/ncc": "^0.34.0", "eslint": "^8.0.1",