From c27e9a1389b7253b215e1bbf7abb327b7accd8f9 Mon Sep 17 00:00:00 2001 From: Bryan Loh Date: Fri, 12 Apr 2024 19:29:52 +0800 Subject: [PATCH] Attempt to fix npm publish workflow --- .github/workflows/publish-npm.yml | 34 ++++++++++++------------------- package.json | 2 +- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index edaeb42..8b1e8d9 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -7,7 +7,7 @@ on: jobs: verify: - name: Verify should publish + name: Publish if pkg version changed runs-on: ubuntu-latest steps: - name: Checkout repository @@ -15,27 +15,19 @@ jobs: with: ref: main submodules: recursive - - name: Verify version has changed + + - name: Get package version + id: get_pkg_version + run: echo "pkg_version=$(cat package.json | jq -r .version)" >> "$GITHUB_OUTPUT" + + - name: Get npm version + id: get_npm_version + run: echo "npm_version=$(npm view java-slang version)" >> "$GITHUB_OUTPUT" + + - name: Stop if version has not changed + if: steps.get_pkg_version.outputs.pkg_version == steps.get_npm_version.outputs.npm_version # We use jq as `npm pkg get version` returns a quoted string - run: | - if [ "$(cat package.json | jq -r .version)" == "$(npm view java-slang version)" ]; then - 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' }} - runs-on: ubuntu-latestg - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: main - submodules: recursive + run: exit 1 - name: Setup Node.js uses: actions/setup-node@v4 with: diff --git a/package.json b/package.json index e9a131f..53c121d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "java-slang", - "version": "1.0.9", + "version": "1.0.10", "main": "dist/index.js", "types": "dist/index.d.ts", "files": ["dist"],