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