-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b1bd2b
commit 76a267e
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
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 }} |