Repository navigation
Publish @flexmonster/react to npm #4
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 @flexmonster/react to npm | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (used for @flexmonster/react and the @flexmonster/js peer dependency)' | |
| required: true | |
| type: string | |
| tag: | |
| description: 'npm dist-tag' | |
| required: true | |
| type: choice | |
| default: latest | |
| options: | |
| - latest | |
| - next | |
| - beta | |
| dry_run: | |
| description: 'Dry run (do not actually publish to npm)' | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| 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' | |
| - name: Update package.json versions | |
| env: | |
| NEW_VERSION: ${{ inputs.version }} | |
| run: | | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | |
| pkg.version = process.env.NEW_VERSION; | |
| if (pkg.peerDependencies && pkg.peerDependencies['@flexmonster/js']) { | |
| pkg.peerDependencies['@flexmonster/js'] = process.env.NEW_VERSION; | |
| } | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| - name: Install dependencies | |
| run: npm install --no-audit --no-fund | |
| - name: Build | |
| run: npm run build | |
| - name: Show package.json after version bump | |
| run: cat package.json | |
| - name: Publish to npm (dry run) | |
| if: ${{ inputs.dry_run }} | |
| run: npm publish --access public --tag ${{ inputs.tag }} --dry-run | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Publish to npm | |
| if: ${{ !inputs.dry_run }} | |
| run: npm publish --access public --tag ${{ inputs.tag }} | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |