0.25.0 #13
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: Publish to npm | |
on: | |
push: | |
branches: main | |
permissions: | |
contents: write | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- run: npm ci | |
- name: Get current npm version | |
id: current_version | |
run: echo "version=$(node -p 'require(`./package.json`).version')" >> $GITHUB_ENV | |
- name: Get previous npm version | |
id: previous_version | |
run: | | |
PREV_VERSION=$(npm view ${{ github.repository }} version) | |
echo "prev_version=${PREV_VERSION}" >> $GITHUB_ENV | |
- name: Check version change | |
id: version_check | |
run: | | |
if [ "${{ env.version }}" != "${{ env.prev_version }}" ]; then | |
echo "changed=true" >> $GITHUB_ENV | |
else | |
echo "changed=false" >> $GITHUB_ENV | |
fi | |
- name: Publish to npm | |
if: env.changed == 'true' | |
uses: JS-DevTools/npm-publish@v3 | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
- name: Create GitHub Release | |
if: env.changed == 'true' | |
uses: actions/create-release@v1 | |
with: | |
tag_name: v${{ env.version }} | |
release_name: Release v${{ env.version }} | |
body: New release v${{ env.version }} | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |