Skip to content

Commit a31391a

Browse files
committed
feat: improved README and added CI workflow
1 parent 846e7a7 commit a31391a

File tree

2 files changed

+212
-188
lines changed

2 files changed

+212
-188
lines changed

.github/workflows/publish.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v4
17+
18+
19+
- name: Install Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
cache: "pnpm"
23+
registry-url: "https://registry.npmjs.org"
24+
25+
- name: Install dependencies
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: Bump version
29+
id: version_bump
30+
run: |
31+
PACKAGE_NAME=$(node -p "require('./package.json').name")
32+
CURRENT_VERSION=$(node -p "require('./package.json').version")
33+
NPM_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "0.0.0")
34+
35+
pnpm add semver
36+
IS_CURRENT_GREATER=$(node -e "console.log(require('semver').gt('$CURRENT_VERSION', '$NPM_VERSION'))")
37+
38+
if [ "$IS_CURRENT_GREATER" = "true" ]; then
39+
echo "Version in package.json ($CURRENT_VERSION) is greater than npm version ($NPM_VERSION). No bump needed."
40+
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
41+
echo "version_changed=false" >> $GITHUB_OUTPUT
42+
else
43+
echo "Bumping version..."
44+
pnpm version prerelease --preid alpha --no-git-tag-version
45+
NEW_VERSION=$(node -p "require('./package.json').version")
46+
echo "New version: $NEW_VERSION"
47+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
48+
echo "version_changed=true" >> $GITHUB_OUTPUT
49+
fi
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
53+
- name: Build
54+
run: pnpm run build
55+
56+
- name: Create a .env file and .env.test file
57+
run: |
58+
echo "NILLION_API_KEY=${{ secrets.NILLION_API_KEY }}" > .env
59+
echo "NILLION_API_KEY=${{ secrets.NILLION_API_KEY }}" > .env.test
60+
61+
- name: Test
62+
run: pnpm run test
63+
64+
- name: Publish to NPM
65+
run: pnpm publish --no-git-checks
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)