Fix package-lock.json version #58
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: test and publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [24.x, 26.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| - run: npm ci | |
| - run: npm test | |
| env: | |
| CI: true | |
| npm-publish: | |
| name: npm-publish | |
| needs: test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 26.x | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Link to stream sub-package | |
| run: echo "module.exports = require('./dist/stream')" > stream.js | |
| - name: Publish to npm if version is updated | |
| run: | | |
| PACKAGE_NAME=$(node -p "require('./package.json').name") | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| if npm view "$PACKAGE_NAME@$CURRENT_VERSION" version &> /dev/null; then | |
| echo "Version $CURRENT_VERSION of $PACKAGE_NAME is already published. Skipping." | |
| else | |
| echo "Publishing version $CURRENT_VERSION of $PACKAGE_NAME..." | |
| npm publish --provenance --access public | |
| # Tag and push back to GitHub | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag "v$CURRENT_VERSION" | |
| git push origin "v$CURRENT_VERSION" | |
| fi |