|
| 1 | +name: Publish (alpha / beta) with specific package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + channel: |
| 7 | + type: choice |
| 8 | + description: NPM channel |
| 9 | + options: |
| 10 | + - alpha |
| 11 | + - beta |
| 12 | + package_name: |
| 13 | + type: string |
| 14 | + description: "Optional: Specify the package to publish (leave empty to publish all changed packages)" |
| 15 | + required: false |
| 16 | + |
| 17 | +permissions: |
| 18 | + contents: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + publish-npm: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + defaults: |
| 24 | + run: |
| 25 | + working-directory: ./ |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v2 |
| 28 | + - uses: actions/setup-node@v1 |
| 29 | + with: |
| 30 | + node-version: 16 |
| 31 | + registry-url: https://registry.npmjs.org/ |
| 32 | + cache-dependency-path: ./package-lock.json |
| 33 | + |
| 34 | + - run: npx lerna@6 bootstrap |
| 35 | + - run: npx lerna@6 run build |
| 36 | + |
| 37 | + - name: Create release (only for all packages) |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + run: | |
| 41 | + if [ -z "${{ github.event.inputs.package_name }}" ]; then |
| 42 | + echo "Creating a release for all packages..." |
| 43 | + RELEASE_TAG=v$(node -p "require('./lerna.json').version") |
| 44 | + gh release create --prerelease $RELEASE_TAG --target=$GITHUB_SHA --title="$RELEASE_TAG" --generate-notes |
| 45 | + else |
| 46 | + echo "Skipping release creation because we're publishing a single package." |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Publish to npmjs |
| 50 | + env: |
| 51 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 52 | + run: | |
| 53 | + if [ -z "${{ github.event.inputs.package_name }}" ]; then |
| 54 | + echo "Publishing all changed packages..." |
| 55 | + npx lerna publish from-package --yes --dist-tag ${{ github.event.inputs.channel }} --pre-dist-tag ${{ github.event.inputs.channel }} |
| 56 | + else |
| 57 | + echo "Publishing only: ${{ github.event.inputs.package_name }}" |
| 58 | +
|
| 59 | + # Publish the specific package |
| 60 | + npx lerna publish from-package --yes --dist-tag ${{ github.event.inputs.channel }} --pre-dist-tag ${{ github.event.inputs.channel }} |
| 61 | + fi |
0 commit comments