Upgrade to node 18

This commit is contained in:
Qiao Han
2022-08-04 00:15:17 +08:00
parent 90fa7bad0f
commit 39cbf44fc1
7 changed files with 58 additions and 72 deletions

View File

@@ -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: |

View File

@@ -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:

View File

@@ -1,84 +1,76 @@
<p align="center">
<a href="https://github.com/actions/typescript-action/actions"><img alt="typescript-action status" src="https://github.com/actions/typescript-action/workflows/build-test/badge.svg"></a>
</p>
# :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
```bash
$ npm install
```
Build the typescript and package it for distribution
```bash
$ npm run build && npm run package
```
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.
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
```
@@ -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

View File

@@ -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/'

View File

@@ -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

14
package-lock.json generated
View File

@@ -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": {

View File

@@ -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",