Skip to content

Commit

Permalink
Fix workflow for publishing to NPM (#1423)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Henz <[email protected]>
  • Loading branch information
RichDom2185 and martin-henz authored Jul 31, 2023
1 parent 66ee980 commit 4b9e97a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
name: Publish to npm

on:
pull_request:
push:
branches:
- master
types: [closed]

jobs:
verify:
name: Verify should publish
runs-on: ubuntu-latest
steps:
- name: Verify PR merged
env:
IS_MERGED: ${{ github.event.pull_request.merged }}
run: |
if [ "$IS_MERGED" != "true" ]; then
echo "Pull request is not merged"; exit 1;
fi
- name: Checkout repository
uses: actions/checkout@v2
with:
Expand All @@ -27,11 +19,16 @@ jobs:
# We use jq as `npm pkg get version` returns a quoted string
run: |
if [ "$(cat package.json | jq -r .version)" == "$(npm view js-slang version)" ]; then
echo "Version has not changed"; exit 1;
echo "Version has not changed"
echo "UPDATE=false" >> "$GITHUB_OUTPUT"
else
echo "Version has changed";
echo "UPDATE=true" >> "$GITHUB_OUTPUT"
fi
publish:
name: Publish to npm
needs: [verify]
if: ${{ needs.verify.outputs.UPDATE == 'true' }}
environment: publish-npm # Await approval from maintainers
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 4b9e97a

Please sign in to comment.