Publish Package to npmjs #4
Workflow file for this run
This file contains hidden or 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: | |
| 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 | |
| npm config set registry https://registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN | |
| npm whoami | |
| VERSION=$(node -p "require('./packages/imagekit-editor/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." | |
| cd packages/imagekit-editor | |
| npm publish --tag "$NPM_TAG" --provenance --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.npm_token}} | |
| CI: true |