Skip to content

Commit

Permalink
Merge pull request #16 from BuidlerDAO/publish-action
Browse files Browse the repository at this point in the history
add publish action file
  • Loading branch information
zhbyak authored Jan 10, 2025
2 parents 7b1bd2b + 76a267e commit 9349283
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish npm package

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm i

- name: Run tests
run: pnpm test

- name: Check if version changed
id: version_check
run: |
git fetch origin main
PREVIOUS_VERSION=$(git show origin/main:package.json | jq -r .version)
CURRENT_VERSION=$(jq -r .version package.json)
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
if [ "$PREVIOUS_VERSION" == "$CURRENT_VERSION" ]; then
echo "Version has not changed. Exiting."
exit 0
fi
- name: Publish to npm
if: ${{ steps.version_check.outputs.current_version != steps.version_check.outputs.previous_version }}
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 9349283

Please sign in to comment.