🚀 Publish to NPM #59
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 to NPM | |
on: | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
deployments: write | |
defaults: | |
run: | |
working-directory: src | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: chrnorm/deployment-action@v2 | |
name: Create GitHub deployment | |
id: deployment | |
with: | |
token: "${{ github.token }}" | |
- uses: actions/cache@v4 | |
env: | |
cache-name: cache-pnpm-modules | |
with: | |
path: ~/.pnpm-store | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}- | |
- uses: pnpm/action-setup@v4.0.0 | |
with: | |
version: 8.15.8 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
registry-url: "https://registry.npmjs.org" | |
cache: "pnpm" | |
cache-dependency-path: src/pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm i | |
- name: Check | |
run: pnpm lint | |
- name: Build CLI tool 🔧 | |
run: pnpm build | |
# Publish version to public repository | |
- name: Publish package on NPM 📦 | |
run: pnpm -r publish --no-git-checks --access=public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Update deployment status (success) | |
if: success() | |
uses: chrnorm/deployment-status@v2 | |
with: | |
token: "${{ github.token }}" | |
environment-url: ${{ steps.deployment.outputs.environment_url }} | |
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
state: "success" | |
- name: Update deployment status (failure) | |
if: failure() | |
uses: chrnorm/deployment-status@v2 | |
with: | |
token: "${{ github.token }}" | |
environment-url: ${{ steps.deployment.outputs.environment_url }} | |
deployment-id: ${{ steps.deployment.outputs.deployment_id }} | |
state: "failure" |