Skip to content

updated workflow to handle beta versions #23

updated workflow to handle beta versions

updated workflow to handle beta versions #23

Workflow file for this run

name: Publish Package
on:
push:
branches:
- main # Triggers on pushes to the main branch
#tags:
# - 'v*.*.*' # Uncomment this if you want to trigger on version tags
jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repository code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20' # Ensure this matches your Node.js version
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Determine publish tag
id: determine_tag
run: |
VERSION=$(node -p "require('./package.json').version")
echo "Package version is $VERSION"
if [[ "$VERSION" == *"-beta"* ]]; then
echo "publish_tag=beta" >> $GITHUB_ENV
else
echo "publish_tag=latest" >> $GITHUB_ENV
fi
- name: Publish to npm
run: npm publish --tag ${{ env.publish_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}