Skip to content

Publish Packages to npm #2

Publish Packages to npm

Publish Packages to npm #2

name: Publish Packages to npm
on:
release:
types: [created]
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- uses: pnpm/action-setup@v3
name: Install pnpm
with:
version: 8
- name: Determine branch from release
id: determine_branch
run: echo ::set-output name=branch::${GITHUB_REF#refs/*/}
- name: Identify package name
id: determine_package
run: echo ::set-output name=package::$(echo ${{ steps.determine_branch.outputs.branch }} | cut -d / -f 2)
- name: Check if package is allowed
run: |
if [[ "${{ steps.determine_package.outputs.package }}" != "$PACKAGE_NAME" ]]; then
echo "Package not allowed. Exiting..."
exit 1
fi
env:
PACKAGE_NAME: ${{ steps.determine_package.outputs.package }}
- name: Install dependencies
run: pnpm -F $PACKAGE_NAME i
- name: Build package
run: pnpm -F $PACKAGE_NAME build
- name: Publish package
run: pnpm -F $PACKAGE_NAME publish --no-git-check
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}