Skip to content

Commit afaeb3c

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

File tree

2 files changed

+213
-188
lines changed

2 files changed

+213
-188
lines changed

.github/workflows/publish.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
node-version: 20
23+
cache: "pnpm"
24+
registry-url: "https://registry.npmjs.org"
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Bump version
30+
id: version_bump
31+
run: |
32+
PACKAGE_NAME=$(node -p "require('./package.json').name")
33+
CURRENT_VERSION=$(node -p "require('./package.json').version")
34+
NPM_VERSION=$(npm view $PACKAGE_NAME version 2>/dev/null || echo "0.0.0")
35+
36+
pnpm add semver
37+
IS_CURRENT_GREATER=$(node -e "console.log(require('semver').gt('$CURRENT_VERSION', '$NPM_VERSION'))")
38+
39+
if [ "$IS_CURRENT_GREATER" = "true" ]; then
40+
echo "Version in package.json ($CURRENT_VERSION) is greater than npm version ($NPM_VERSION). No bump needed."
41+
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
42+
echo "version_changed=false" >> $GITHUB_OUTPUT
43+
else
44+
echo "Bumping version..."
45+
pnpm version prerelease --preid alpha --no-git-tag-version
46+
NEW_VERSION=$(node -p "require('./package.json').version")
47+
echo "New version: $NEW_VERSION"
48+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
49+
echo "version_changed=true" >> $GITHUB_OUTPUT
50+
fi
51+
env:
52+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53+
54+
- name: Build
55+
run: pnpm run build
56+
57+
- name: Create a .env file and .env.test file
58+
run: |
59+
echo "NILLION_API_KEY=${{ secrets.NILLION_API_KEY }}" > .env
60+
echo "NILLION_API_KEY=${{ secrets.NILLION_API_KEY }}" > .env.test
61+
62+
- name: Test
63+
run: pnpm run test
64+
65+
- name: Publish to NPM
66+
run: pnpm publish --no-git-checks
67+
env:
68+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)