Merge branch 'main' of https://github.com/sista-ai/vuic-react-sdk #37
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: VUIC React - Build and Publish to NPM | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Necessary for actions/checkout to fetch all history for versioning and tagging | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Get current version | |
id: pkg | |
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
- name: Check if tag exists | |
run: | | |
NEW_TAG=$(npm version patch --git-tag-version=false) | |
if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then | |
echo "tag exists" | |
git tag -d $NEW_TAG | |
git push origin :refs/tags/$NEW_TAG | |
else | |
echo "tag does not exist" | |
fi | |
- name: Automatic Version Bump | |
id: bump | |
uses: phips28/gh-action-bump-version@v9.1.1 | |
with: | |
tag-prefix: '' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to npm | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |