Skip to content

Commit

Permalink
feat: Add npm publish GitHub Action workflow (#2762)
Browse files Browse the repository at this point in the history
* feat: Add npm publish GitHub Action workflow

* Fix typo
  • Loading branch information
dolanmiu authored Oct 13, 2024
1 parent 2d2e4cd commit 07f363f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- uses: "./.github/actions/install-and-build"
- name: Archive Production Artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: build
path: build
Expand All @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Test
Expand All @@ -42,7 +42,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Lint
Expand All @@ -52,7 +52,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Prettier
Expand All @@ -62,7 +62,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Prettier
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Demos
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: "./.github/actions/install-and-build"
- name: Run Demos
run: npm run run-ts -- ./demo/1-basic.ts
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Build 🔧
Expand All @@ -19,7 +19,7 @@ jobs:
echo "docx.js.org" > docs/.nojekyll
echo "docx.js.org" > docs/CNAME
- name: Archive Production Artifact
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: docs
path: docs
Expand All @@ -28,16 +28,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo 🛎️
uses: actions/checkout@master
uses: actions/checkout@v4
- name: Install Dependencies
run: npm ci --force
- name: Download Artifact
uses: actions/download-artifact@master
uses: actions/download-artifact@v4
with:
name: docs
path: docs
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.5
uses: JamesIves/github-pages-deploy-action@v4.1.5
with:
branch: gh-pages
folder: docs
46 changes: 46 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci
- run: npm run cspell
- run: npm run prettier
- run: npm run lint
- run: npm run test:ci

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
- run: npm ci
- run: npm run build

publish-npm:
needs: [test, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.x"
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

0 comments on commit 07f363f

Please sign in to comment.