Skip to content

debug with version roll #14

debug with version roll

debug with version roll #14

Workflow file for this run

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: |
CURRENT_VERSION=$(node -p 'require(`./package.json`).version')
echo "current_version=${CURRENT_VERSION}" >> $GITHUB_ENV
echo "Current npm version: ${CURRENT_VERSION}"
- name: Get previous npm version
id: previous_version
run: |
PREV_VERSION=$(npm show $(node -p 'require(`./package.json`).name') version)
echo "prev_version=${PREV_VERSION}" >> $GITHUB_ENV
echo "Previous npm version: ${PREV_VERSION}"
- name: Check version change
id: version_check
run: |
if [ "${{ env.current_version }}" != "${{ env.prev_version }}" ]; then
echo "changed=true" >> $GITHUB_ENV
else
echo "changed=false" >> $GITHUB_ENV
fi
echo "Version changed: ${{ env.changed }}"
- 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.current_version }}
release_name: Release v${{ env.current_version }}
body: New release v${{ env.current_version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}