Skip to content

Commit

Permalink
Merge pull request #5 from Hexastack/build/npm-versioning
Browse files Browse the repository at this point in the history
build: npm versioning
  • Loading branch information
marrouchi authored Dec 12, 2024
2 parents 3839b2f + 7481d13 commit 829a46c
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Publish NPM Package

on:
push:
tags:
- 'v*'
workflow_dispatch: # Allow manual trigger

jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: 'package.json'

- name: Determine release type
id: determine-release
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "release=minor" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "release=patch" >> $GITHUB_ENV
else
echo "release=none" >> $GITHUB_ENV
fi
else
echo "release=none" >> $GITHUB_ENV
fi
- name: Login to npm
if: env.release != 'none'
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org/'
node-version: '18'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to npm
if: env.release != 'none'
run: npm publish
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
"ollama": "^0.5.9"
},
"scripts": {
"release:common": "git push origin --tags && npm publish",
"release:patch": "npm version patch && npm run release:common",
"release:minor": "npm version minor && npm run release:common",
"release": "echo 'Please specify patch or minor: npm run release:patch or npm run release:minor'"
"release:patch": "npm version patch && git push origin main --tags",
"release:minor": "npm version minor && git push origin main --tags"
},
"author": "Hexastack",
"license": "AGPL-3.0-only"
Expand Down

0 comments on commit 829a46c

Please sign in to comment.