|
| 1 | +name: Release CLI Plugin Packages |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - uses: pnpm/action-setup@v4 |
| 14 | + with: |
| 15 | + version: 10 |
| 16 | + |
| 17 | + - uses: actions/setup-node@v4 |
| 18 | + with: |
| 19 | + node-version: '22.x' |
| 20 | + registry-url: 'https://registry.npmjs.org' |
| 21 | + cache: 'pnpm' |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + run: pnpm install --frozen-lockfile |
| 25 | + |
| 26 | + - name: Build all packages |
| 27 | + run: | |
| 28 | + pnpm --filter @contentstack/cli-variants compile |
| 29 | + pnpm --filter './packages/*' -w build |
| 30 | +
|
| 31 | + - name: Reading Configuration |
| 32 | + id: release_config |
| 33 | + uses: rgarcia-phi/json-to-variables@v1.1.0 |
| 34 | + with: |
| 35 | + filename: .github/config/release.json |
| 36 | + prefix: release |
| 37 | + |
| 38 | + - name: Prepare for publishing |
| 39 | + run: node scripts/prepare-publish.js |
| 40 | + |
| 41 | + # Publish variants (base dependency for plugins) |
| 42 | + - name: Publishing variants |
| 43 | + uses: JS-DevTools/npm-publish@v3 |
| 44 | + if: ${{env.release_releaseAll == 'true' || env.release_plugins_variants == 'true'}} |
| 45 | + with: |
| 46 | + token: ${{ secrets.NPM_TOKEN }} |
| 47 | + package: ./packages/contentstack-variants/package.json |
| 48 | + access: public |
| 49 | + |
| 50 | + # Publish audit |
| 51 | + - name: Publishing audit |
| 52 | + uses: JS-DevTools/npm-publish@v3 |
| 53 | + if: ${{env.release_releaseAll == 'true' || env.release_plugins_audit == 'true'}} |
| 54 | + with: |
| 55 | + token: ${{ secrets.NPM_TOKEN }} |
| 56 | + package: ./packages/contentstack-audit/package.json |
| 57 | + access: public |
| 58 | + |
| 59 | + # Publish export (depends on variants) |
| 60 | + - name: Publishing export |
| 61 | + uses: JS-DevTools/npm-publish@v3 |
| 62 | + if: ${{env.release_releaseAll == 'true' || env.release_plugins_export == 'true'}} |
| 63 | + with: |
| 64 | + token: ${{ secrets.NPM_TOKEN }} |
| 65 | + package: ./packages/contentstack-export/package.json |
| 66 | + |
| 67 | + # Publish import (depends on variants and audit) |
| 68 | + - name: Publishing import |
| 69 | + uses: JS-DevTools/npm-publish@v3 |
| 70 | + if: ${{env.release_releaseAll == 'true' || env.release_plugins_import == 'true'}} |
| 71 | + with: |
| 72 | + token: ${{ secrets.NPM_TOKEN }} |
| 73 | + package: ./packages/contentstack-import/package.json |
| 74 | + |
| 75 | + # Publish clone (depends on export and import) |
| 76 | + - name: Publishing clone |
| 77 | + id: publish-clone |
| 78 | + uses: JS-DevTools/npm-publish@v3 |
| 79 | + if: ${{env.release_releaseAll == 'true' || env.release_plugins_clone == 'true'}} |
| 80 | + with: |
| 81 | + token: ${{ secrets.NPM_TOKEN }} |
| 82 | + package: ./packages/contentstack-clone/package.json |
| 83 | + |
| 84 | + # Restore workspace protocol after publishing |
| 85 | + - name: Restore workspace protocol |
| 86 | + if: always() |
| 87 | + run: git restore packages/*/package.json |
| 88 | + |
| 89 | + # Create release on success |
| 90 | + - name: Create Release |
| 91 | + if: ${{ steps.publish-clone.conclusion == 'success' }} |
| 92 | + id: create_release |
| 93 | + env: |
| 94 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + VERSION: ${{ steps.publish-clone.outputs.version }} |
| 96 | + run: gh release create v"$VERSION" --title "Release $VERSION" --generate-notes |
0 commit comments