Skip to content

Commit b6b5e1a

Browse files
authored
Include github action to publish when in master and new version defined (#6)
1 parent 590ef65 commit b6b5e1a

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Publish to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
id-token: write # Required for OIDC
11+
12+
jobs:
13+
publish:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '24'
23+
registry-url: 'https://registry.npmjs.org'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Build library
29+
run: npm run pack-lib
30+
31+
- name: Check if version exists
32+
id: check_version
33+
run: |
34+
PACKAGE_NAME=$(node -p "require('./package.json').name")
35+
VERSION=$(node -p "require('./package.json').version")
36+
echo "Checking if $PACKAGE_NAME@$VERSION exists..."
37+
38+
if npm view "$PACKAGE_NAME@$VERSION" version &>/dev/null; then
39+
echo "Version $VERSION already exists in registry"
40+
echo "should_publish=false" >> $GITHUB_OUTPUT
41+
else
42+
echo "Version $VERSION does not exist, will publish"
43+
echo "should_publish=true" >> $GITHUB_OUTPUT
44+
fi
45+
working-directory: ./dist/ngx-appshell
46+
47+
- name: Publish to npm
48+
if: steps.check_version.outputs.should_publish == 'true'
49+
run: npm publish --access public
50+
working-directory: ./dist/ngx-appshell

0 commit comments

Comments
 (0)