Skip to content

Merge pull request #2 from Codegyan-LLC/dev #14

Merge pull request #2 from Codegyan-LLC/dev

Merge pull request #2 from Codegyan-LLC/dev #14

Workflow file for this run

# 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: Release Git Package & Publish on NPM
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
steps:
# Checkout repo
- name: Checkout code
uses: actions/checkout@v4
# Setup Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'
# Install deps
- name: Install dependencies
run: npm install
# Bump version dynamically & push tag
- name: Bump version
id: version
run: |
# Author identity
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Bump patch version (you can change to minor/major if needed)
NEW_VERSION=$(npm version patch -m "chore(release): v%s [skip ci]")
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
# Push updated package.json and tag to main
- name: Push changes
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
tags: true
# Create GitHub Release
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.new_version }}
name: Release ${{ steps.version.outputs.new_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Publish to NPM
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}