Publish NPM Packages #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish NPM Packages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| packages: | |
| description: 'Which packages to publish' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - ison-js | |
| - ison-ts | |
| dry_run: | |
| description: 'Dry run (no actual publish)' | |
| required: false | |
| default: true | |
| type: boolean | |
| jobs: | |
| publish-base: | |
| name: Publish Base Packages | |
| runs-on: ubuntu-latest | |
| if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-js' || inputs.packages == 'ison-ts' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| # NOTE: there is no root package.json -- this repo is not an npm | |
| # workspace, so every npm step runs inside its own package directory. | |
| - name: Build and test ison-js | |
| if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-js' }} | |
| working-directory: ison-js | |
| run: | | |
| npm ci | |
| mkdir -p dist | |
| npm run build | |
| npm test | |
| - name: Publish ison-js | |
| if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-js' }} | |
| working-directory: ison-js | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| npm publish --dry-run | |
| else | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Build and test ison-ts | |
| if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-ts' }} | |
| working-directory: ison-ts | |
| run: | | |
| npm ci | |
| npm run build | |
| npm test | |
| - name: Publish ison-ts | |
| if: ${{ inputs.packages == 'all' || inputs.packages == 'ison-ts' }} | |
| working-directory: ison-ts | |
| run: | | |
| if [ "${{ inputs.dry_run }}" = "true" ]; then | |
| npm publish --dry-run | |
| else | |
| npm publish --access public | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |