Update README.md #54
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: Release and publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish-npm: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org' | |
- name: Check if version has been incremented | |
id: check-version | |
run: | | |
PACKAGE_NAME=$(node -p "require('./package.json').name") | |
VERSION=$(node -p "require('./package.json').version") | |
CURRENT_VERSION=$(npm view $PACKAGE_NAME version) | |
if [ "$VERSION" != "$CURRENT_VERSION" ]; then | |
echo "::set-output name=version_changed::true" | |
echo "::set-output name=new_version::$VERSION" | |
fi | |
- name: Create GitHub release | |
if: steps.check-version.outputs.version_changed == 'true' | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.check-version.outputs.new_version }} | |
release_name: v${{ steps.check-version.outputs.new_version }} | |
draft: false | |
prerelease: false | |
- name: Publish to npm | |
if: steps.check-version.outputs.version_changed == 'true' | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |