updated workflow to handle beta versions #23
This file contains 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 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 }} |