|
| 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 |
0 commit comments