Publish Package to npmjs #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package to npmjs | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "The version to publish" | |
required: true | |
tag: | |
description: "Tag" | |
required: true | |
default: "latest" | |
type: choice | |
options: | |
- latest | |
- snapshot | |
- next | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Begin CI... | |
uses: actions/checkout@v4 | |
- name: Use Node 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
registry-url: "https://registry.npmjs.org" | |
- name: Use cached node_modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: nodeModules-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
nodeModules- | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
env: | |
CI: true | |
- name: Lint | |
run: yarn lint | |
env: | |
CI: true | |
- name: Test | |
run: yarn test | |
env: | |
CI: true | |
- name: Build | |
run: yarn build | |
env: | |
CI: true | |
- run: npm pkg set "version=${{ inputs.version }}" | |
- run: npm publish --provenance --tag ${{ inputs.tag }} --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |