ci: add automated test publishing on push #12
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: Node.js build and publish package | |
| on: | |
| release: | |
| types: [ created ] | |
| push: | |
| branches: | |
| - '**' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| - run: npm i | |
| publish-npm: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| - run: npm i | |
| - name: Publish Release | |
| if: github.event_name == 'release' | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
| - name: Publish Test Version | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| env: | |
| NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
| run: | | |
| BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
| echo "Branch: $BRANCH_NAME" | |
| # Determine the new version | |
| NEW_VERSION=$(node scripts/bump-version.js "$BRANCH_NAME") | |
| echo "New Version: $NEW_VERSION" | |
| # Set the version in package.json | |
| npm version $NEW_VERSION --no-git-tag-version | |
| # Publish with 'test' tag | |
| npm publish --tag test |