Skip to content

Commit 5d7d472

Browse files
committed
auto-publish for flamegraph npm package
commit_hash:309b5a2f2c50f9fde976419df4d260d89bf54b3e
1 parent 51abb84 commit 5d7d472

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

.github/workflows/ui-release.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: UI Libraries Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'perforator/ui/packages/*/package.json'
9+
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-24.04
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Install pnpm
17+
uses: pnpm/action-setup@v4
18+
with:
19+
version: 9.12.3
20+
- name: Use Node.js 20
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20.18.1
24+
- name: Install dependencies
25+
working-directory: perforator/ui/app
26+
run: pnpm install
27+
- name: "Set token"
28+
run: |
29+
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
30+
env:
31+
NPM_TOKEN: ${{ secrets.NPMJS_TOKEN }}
32+
- name: Build
33+
working-directory: perforator/ui/app
34+
run: |
35+
pnpm --filter '../packages/*' run build
36+
- name: Check if version exists
37+
id: version-check
38+
working-directory: perforator/ui/app
39+
run: |
40+
# Loop through each package
41+
for pkg in ../packages/*; do
42+
if [ -d "$pkg" ]; then
43+
cd "$pkg"
44+
45+
# Get package name and version
46+
PKG_NAME=$(npm pkg get name | tr -d '"')
47+
PKG_VERSION=$(npm pkg get version | tr -d '"')
48+
49+
echo "Checking if $PKG_NAME@$PKG_VERSION exists..."
50+
51+
# Check if version exists in npm registry
52+
if npm show "$PKG_NAME" --json | grep -q "\"$PKG_VERSION\""; then
53+
echo "Version $PKG_VERSION of $PKG_NAME already exists in npm registry. Skipping."
54+
echo "SKIP_PUBLISH_$(echo $PKG_NAME | tr '@/.-' '_')"=true >> $GITHUB_ENV
55+
else
56+
echo "Version $PKG_VERSION of $PKG_NAME does not exist in npm registry. Will publish."
57+
echo "SKIP_PUBLISH_$(echo $PKG_NAME | tr '@/.-' '_')"=false >> $GITHUB_ENV
58+
fi
59+
60+
cd - > /dev/null
61+
fi
62+
done
63+
64+
- name: Publish
65+
working-directory: perforator/ui/app
66+
run: |
67+
pnpm --filter '../packages/*' run delete-engines
68+
69+
# Loop through each package and only publish if version doesn't exist
70+
for pkg in ../packages/*; do
71+
if [ -d "$pkg" ]; then
72+
cd "$pkg"
73+
PKG_NAME=$(npm pkg get name | tr -d '"')
74+
PKG_SAFE_NAME=$(echo $PKG_NAME | tr '@/.-' '_')
75+
76+
# Check if we should skip publishing this package
77+
if [ "$(eval echo \$SKIP_PUBLISH_$PKG_SAFE_NAME)" != "true" ]; then
78+
echo "Publishing $PKG_NAME..."
79+
npm publish --tag latest --access public
80+
else
81+
echo "Skipping publish for $PKG_NAME as version already exists"
82+
fi
83+
84+
cd - > /dev/null
85+
fi
86+
done

.mapping.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
".gitattributes":"perforator/opensource/github_toplevel/.gitattributes",
44
".github/workflows/postcommit.yaml":"perforator/opensource/github_toplevel/.github/workflows/postcommit.yaml",
55
".github/workflows/release.yaml":"perforator/opensource/github_toplevel/.github/workflows/release.yaml",
6+
".github/workflows/ui-release.yaml":"perforator/opensource/github_toplevel/.github/workflows/ui-release.yaml",
67
".gitignore":"perforator/opensource/github_toplevel/.gitignore",
78
"CONTRIBUTING.md":"perforator/opensource/github_toplevel/CONTRIBUTING.md",
89
"LICENSE":"perforator/opensource/github_toplevel/LICENSE",

perforator/ui/packages/flamegraph/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"typescript": "5.3.3"
2222
},
2323
"scripts": {
24+
"delete-engines": "npm pkg delete engines",
2425
"test": "jest",
2526
"build": "tsc && node scripts/copy-through.mjs"
2627
},

perforator/ui/packages/flamegraph/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"declaration": true,
1616
"declarationDir": "dist",
1717
"jsx": "react",
18-
"target": "es2020"
18+
"target": "es2020",
19+
"declarationMap": true
1920
}
2021
}

0 commit comments

Comments
 (0)