Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run tests
on:
workflow_call:
secrets:
NPM_PUBLISH:
required: true

permissions:
id-token: write
contents: read

jobs:
install:
runs-on: ubuntu-latest
environment: publish
permissions:
contents: read
id-token: write

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: NPM install
run: |
npm ci

- name: Version
if: github.event_name == 'release' && github.event.action == 'created'
run: |
VERSION=${{ github.event.release.tag_name }}
VERSION=${VERSION:1}
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
if [ "$CURRENT_VERSION" != "$VERSION" ]; then
npm version $VERSION --no-git-tag-version
else
echo "Version already set to $VERSION, skipping npm version command"
fi

- uses: step-security/wait-for-secrets@v1
id: wait-for-secrets
with:
secrets: |
OTP:
name: 'OTP to publish package'
description: 'NPM 2FA'

- name: publish
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH }}
run: |
npm publish --otp ${{ steps.wait-for-secrets.outputs.OTP }} --access public
118 changes: 118 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Run tests
on:
workflow_call:

permissions:
id-token: write
contents: read

jobs:
install:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
with:
path: ./node_modules
key: node-${{ hashFiles('./package-lock.json') }}

- name: Install dependencies
if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
run: |
npm ci

audit:
runs-on: ubuntu-latest
needs: [install]
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
with:
path: ./node_modules
key: node-${{ hashFiles('./package-lock.json') }}

- name: audit
run: |
npm audit

test:
runs-on: ubuntu-latest
needs: [install]
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
with:
path: ./node_modules
key: node-${{ hashFiles('./package-lock.json') }}

- name: audit
run: |
npm test

lint:
runs-on: ubuntu-latest
needs: [install]
permissions:
contents: read

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: Cache node modules
id: cache-npm
uses: actions/cache@v4
with:
path: ./node_modules
key: node-${{ hashFiles('./package-lock.json') }}

- name: audit
run: |
npm run lint