Skip to content

chore: fix gh action npm to yarn #2

chore: fix gh action npm to yarn

chore: fix gh action npm to yarn #2

Workflow file for this run

name: Publish to npm
on:
push:
branches:
- ixo
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
scope: '@ixo'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
run: yarn build
- name: Check if version changed
id: version-check
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
NPM_VERSION=$(npm view @ixo/matrix-bot-sdk version 2>/dev/null || echo "0.0.0")
if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "Version changed from $NPM_VERSION to $PACKAGE_VERSION"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "Version $PACKAGE_VERSION already published"
fi
- name: Publish to npm
if: steps.version-check.outputs.changed == 'true'
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}