Skip to content

ci: add automated test publishing on push #12

ci: add automated test publishing on push

ci: add automated test publishing on push #12

Workflow file for this run

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