hexabot/.github/workflows/widget-npm.yml

59 lines
1.6 KiB
YAML
Raw Normal View History

2024-12-10 09:56:49 +00:00
name: Publish Hexabot Widget NPM Package
on:
push:
tags:
- 'v*'
workflow_dispatch: # Allow manual trigger
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18' # Ensure it matches your project requirements
cache: 'npm'
- name: Install dependencies
2024-12-10 13:05:53 +00:00
working-directory: widget
2024-12-10 13:15:26 +00:00
run: npm ci --ignore-scripts
2024-12-10 09:56:49 +00:00
- name: Build the package
2024-12-10 13:05:53 +00:00
working-directory: widget
2024-12-10 13:15:26 +00:00
run: npm run build
2024-12-10 09:56:49 +00:00
- name: Determine release type
id: determine-release
run: |
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
echo "tag=${{ github.ref_name }}" >> $GITHUB_ENV
if [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.0$ ]]; then
echo "release=minor" >> $GITHUB_ENV
elif [[ "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "release=patch" >> $GITHUB_ENV
else
echo "release=none" >> $GITHUB_ENV
fi
else
echo "release=none" >> $GITHUB_ENV
fi
- name: Login to npm
if: env.release != 'none'
uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org/'
node-version: '18'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish to npm
2024-12-10 13:15:26 +00:00
working-directory: widget
2024-12-10 09:56:49 +00:00
if: env.release != 'none'
2024-12-10 13:05:53 +00:00
run: npm publish