Skip to content

Publish Package to npmjs #2

Publish Package to npmjs

Publish Package to npmjs #2

Workflow file for this run

name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: ⬇️ Check out code
uses: actions/checkout@v4
- name: 🟢 Enable Corepack
run: corepack enable
- name: 🟢 Set up Node 20
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
registry-url: 'https://registry.npmjs.org'
- name: Build and Publish
run: |
yarn install --frozen-lockfile
yarn build
# print the NPM user name for validation
npm whoami
VERSION=$(node -p "require('./package.json').version" )
# Only publish stable versions to the latest tag
if [[ "$VERSION" =~ ^[^-]+$ ]]; then
NPM_TAG="latest"
else
NPM_TAG="beta"
fi
echo "Publishing $VERSION with $NPM_TAG tag."
yarn workspace @imagekit/editor npm publish --tag "$NPM_TAG" --provenance --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
CI: true