Merge pull request #5 from the-qa-company/feature/package-bump #55
This file contains hidden or 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
| on: | |
| push: | |
| branches: | |
| - "main" | |
| env: | |
| npm_config_yes: true | |
| jobs: | |
| tag-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Git user | |
| run: | | |
| git config user.name github-actions | |
| git config user.email [email protected] | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 16 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Read version | |
| id: "read-version" | |
| run: echo "::set-output name=version::$(cat package.json | npx json version)" | |
| - run: "echo \"Version found in package.json: ${{ steps.read-version.outputs.version }}\"" | |
| - name: Check if tag exists | |
| id: "check-tag" | |
| run: echo "::set-output name=exists::$([[ `git tag -l "v${{ steps.read-version.outputs.version }}"` ]] && echo true || echo false)" | |
| - run: "echo \"Tag exists: ${{ steps.check-tag.outputs.exists }}\"" | |
| - name: Create and push tag | |
| if: ${{ steps.check-tag.outputs.exists == 'false' }} | |
| run: | | |
| git tag "v${{ steps.read-version.outputs.version }}" | |
| git push --tags | |
| - name: Publish to NPM | |
| if: ${{ steps.check-tag.outputs.exists == 'false' }} | |
| run: | | |
| npm install | |
| npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |