Skip to content

chore: update SDK to v0.2.3-beta #1

chore: update SDK to v0.2.3-beta

chore: update SDK to v0.2.3-beta #1

Workflow file for this run

name: Publish to npm
on:
push:
branches: [main]
paths:
- 'package.json'
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.check.outputs.should_publish }}
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Check version change
id: check
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "should_publish=true" >> $GITHUB_OUTPUT
exit 0
fi
git show HEAD~1:package.json > /tmp/old.json 2>/dev/null || {
echo "should_publish=true" >> $GITHUB_OUTPUT
exit 0
}
OLD_VERSION=$(node -p "require('/tmp/old.json').version" || echo "")
if [ "$VERSION" != "$OLD_VERSION" ]; then
echo "should_publish=true" >> $GITHUB_OUTPUT
else
echo "should_publish=false" >> $GITHUB_OUTPUT
fi
publish:
needs: check-version
if: needs.check-version.outputs.should_publish == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
environment:
name: npm
url: https://www.npmjs.com/package/@xdevplatform/xdk
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run build
- run: npm test
- name: Publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ needs.check-version.outputs.version }}" -m "v${{ needs.check-version.outputs.version }}" || true
git push origin "v${{ needs.check-version.outputs.version }}" || true
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.check-version.outputs.version }}
generate_release_notes: true