Skip to content

Commit

Permalink
publish by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
sashankaryal committed Oct 18, 2024
1 parent 81210e6 commit e253483
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages

name: Node.js Package
name: Deploy Package to NPM

on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
publish_npm:
name: Publishing to NPM

publish-npm:
needs: build
runs-on: ubuntu-latest

permissions:
actions: write
contents: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v3

- name: Setup NodeJs
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish

- name: Install Packages
run: npm ci

- name: Bump Version of package.json
uses: ramonpaolo/[email protected]
with:
tag: ${{ github.ref_name }} # Accessing the context and get the reference_name, that in this case, is the tag that you created(ex: v1.0.0)
commit: true
branch_to_push: "main"

- name: Publish package to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # NPM Token necessary to deploy packages on pipelines CI/CD

0 comments on commit e253483

Please sign in to comment.