Merge pull request #24 from epsilla-cloud/hybrid_search #17
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: Build and Publish to npm | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: ['14.x', '16.x', '20.4.0'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
publish: | |
needs: build-and-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Extract version from package.json | |
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
- name: Check if version already published | |
run: | | |
echo "Checking version: ${{ env.VERSION }}" | |
NPM_VIEW_OUTPUT=$(npm view epsillajs@${{ env.VERSION }}) | |
echo "npm view output: $NPM_VIEW_OUTPUT" | |
if [ -n "$NPM_VIEW_OUTPUT" ]; then | |
echo "Version ${{ env.VERSION }} already exists on npm. Please update the version." | |
exit 1 | |
fi | |
- name: Bump version and push tag | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.PAT_TOKEN }} | |
tag_prefix: "v" | |
custom_tag: ${{ env.VERSION }} | |
dry_run: false | |
- name: Publish to npm | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} |