Skip to content

Commit 35de513

Browse files
Merge pull request #1 from Codegyan-LLC/dev
update git action file
2 parents 7081850 + 5f96717 commit 35de513

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

.github/workflows/npm-publish.yml

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
11
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
22
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
33

4-
name: Node.js Package
4+
name: Release Git Package & Publish on NPM
55

66
on:
7-
release:
8-
types: [created]
7+
push:
8+
branches:
9+
- main
910

1011
jobs:
11-
build:
12+
release:
1213
runs-on: ubuntu-latest
14+
1315
steps:
14-
- uses: actions/checkout@v4
15-
- uses: actions/setup-node@v4
16+
# Checkout repo
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
# Setup Node.js
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
1623
with:
17-
node-version: 24
18-
- run: npm run build
24+
node-version: '20'
25+
registry-url: 'https://registry.npmjs.org/'
1926

20-
- name: Change directory to dist
21-
run: cd dist
27+
# Install deps
28+
- name: Install dependencies
29+
run: npm install
2230

23-
publish-npm:
24-
needs: build
25-
runs-on: ubuntu-latest
26-
steps:
27-
- uses: actions/checkout@v4
28-
- uses: actions/setup-node@v4
31+
# Bump version dynamically & push tag
32+
- name: Bump version
33+
id: version
34+
run: |
35+
# Bump patch version (you can change to minor/major if needed)
36+
NEW_VERSION=$(npm version patch -m "chore(release): v%s [skip ci]")
37+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
38+
39+
# Push updated package.json and tag to main
40+
- name: Push changes
41+
uses: ad-m/github-push-action@v0.8.0
42+
with:
43+
github_token: ${{ secrets.GITHUB_TOKEN }}
44+
branch: main
45+
tags: true
46+
47+
# Create GitHub Release
48+
- name: Create GitHub Release
49+
uses: softprops/action-gh-release@v2
2950
with:
30-
node-version: 24
31-
registry-url: https://registry.npmjs.org/
32-
33-
- name: Publish to npm
34-
run: npm publish --access public
51+
tag_name: ${{ steps.version.outputs.new_version }}
52+
name: Release ${{ steps.version.outputs.new_version }}
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
56+
# Publish to NPM
57+
- name: Publish to NPM
58+
run: npm publish
3559
env:
36-
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)