Skip to content

Commit 5f1ccde

Browse files
committed
add release-npm.yml
1 parent 140d008 commit 5f1ccde

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

.github/workflows/release-npm.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Check if version changed
18+
id: version-check
19+
run: |
20+
PACKAGE_VERSION=$(jq -r '.version' package.json)
21+
NPM_VERSION=$(npm view @ampcode/svelte-check-daemon version 2>/dev/null || echo "0.0.0")
22+
if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
23+
echo "changed=true" >> $GITHUB_OUTPUT
24+
echo "Version changed: $NPM_VERSION -> $PACKAGE_VERSION"
25+
else
26+
echo "changed=false" >> $GITHUB_OUTPUT
27+
echo "Version unchanged: $PACKAGE_VERSION"
28+
fi
29+
30+
- name: Setup pnpm
31+
if: steps.version-check.outputs.changed == 'true'
32+
uses: pnpm/action-setup@v4
33+
34+
- name: Setup Node.js
35+
if: steps.version-check.outputs.changed == 'true'
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: 20
39+
registry-url: https://registry.npmjs.org
40+
41+
- name: Install dependencies
42+
if: steps.version-check.outputs.changed == 'true'
43+
run: pnpm install
44+
45+
- name: Publish to npm
46+
if: steps.version-check.outputs.changed == 'true'
47+
run: pnpm publish --access public --no-git-checks

0 commit comments

Comments
 (0)