Skip to content

Commit 1eb0835

Browse files
committed
chore: adding npm publish package
1 parent 13be24c commit 1eb0835

File tree

1 file changed

+54
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)