Skip to content

Commit 5815483

Browse files
committed
chore: adding npm publish package
[ci skip]
1 parent a704f97 commit 5815483

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release shared js code
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Version to release (e.g., 1.0.0)'
7+
required: true
8+
type: string
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
- name: Check branch is main
16+
run: |
17+
if [[ "${{ github.ref }}" != "refs/heads/main" ]]; then
18+
echo "Error: This workflow can only be run from the main branch"
19+
exit 1
20+
fi
21+
echo "Branch check passed: running from main branch"
22+
- name: Validate version format
23+
run: |
24+
version="${{ github.event.inputs.version }}"
25+
if ! [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$ ]]; then
26+
echo "Error: Version must be a valid semantic version (e.g., 1.0.0, 1.0.0-beta.1, 1.0.0+build.1)"
27+
exit 1
28+
fi
29+
echo "Version format is valid: $version"
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20'
34+
registry-url: 'https://registry.npmjs.org'
35+
- name: Install pnpm
36+
uses: pnpm/action-setup@v4
37+
with:
38+
version: 10
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
- name: Update package.json version
42+
working-directory: web/shared_ui
43+
run: |
44+
npm version ${{ github.event.inputs.version }} --no-git-tag-version
45+
- name: Build package
46+
working-directory: web/shared_ui
47+
run: pnpm run build
48+
- name: Publish to npm
49+
working-directory: web/shared_ui
50+
run: |
51+
npm publish
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)