From 194ec7f19e07af1b7a351420a2c1d0f4a56fc9bf Mon Sep 17 00:00:00 2001 From: Jayan Ratna Date: Wed, 24 Apr 2024 09:26:34 +1200 Subject: [PATCH 1/2] feat: Automate NPM release --- .github/workflows/release.yml | 34 ++++++++++++++++++++++++++++++++++ package.json | 3 +++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b56a673 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,34 @@ +name: Release + +on: + # Support manually pushing a new release + workflow_dispatch: {} + # Trigger when a release is published + release: + types: [released] + +jobs: + release: + runs-on: ubuntu-latest + + name: Publish to NPM + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: 'https://registry.npmjs.org' + + - name: Clean install dependencies + run: | + npm ci + + - name: Publish to NPM + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + npm publish diff --git a/package.json b/package.json index 4c1723f..08e837b 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", + "files": [ + "dist/" + ], "repository": { "type": "git", "url": "git://github.com/blutui/blutui-node.git" From 07a65d79c60b75c93575e633369299569050856e Mon Sep 17 00:00:00 2001 From: Jayan Ratna Date: Wed, 24 Apr 2024 09:31:30 +1200 Subject: [PATCH 2/2] add test step to release workflow --- .github/workflows/release.yml | 4 ++++ .github/workflows/tests.yml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b56a673..3eaef14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,10 @@ jobs: run: | npm ci + - name: Run tests + run: | + npm run test + - name: Publish to NPM env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c9f4bb5..a00a2b6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,6 @@ jobs: run: | npm install - - name: Test + - name: Run tests run: | npm run test