Skip to content

Commit 95e84eb

Browse files
committed
Attempt to fix npm publish workflow
1 parent 92d6cc0 commit 95e84eb

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

.github/workflows/publish-npm.yml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,38 @@ on:
77

88
jobs:
99
verify:
10-
name: Verify should publish
10+
name: Publish if pkg version changed
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
1515
with:
1616
ref: main
1717
submodules: recursive
18-
- name: Verify version has changed
19-
# We use jq as `npm pkg get version` returns a quoted string
20-
run: |
21-
if [ "$(cat package.json | jq -r .version)" == "$(npm view java-slang version)" ]; then
22-
echo "Version has not changed"
23-
echo "UPDATE=false" >> "$GITHUB_OUTPUT"
24-
else
25-
echo "Version has changed";
26-
echo "UPDATE=true" >> "$GITHUB_OUTPUT"
27-
fi
28-
publish:
29-
name: Publish to npm
30-
needs: [verify]
31-
if: ${{ needs.verify.outputs.UPDATE == 'true' }}
32-
runs-on: ubuntu-latestg
33-
steps:
34-
- name: Checkout repository
35-
uses: actions/checkout@v4
36-
with:
37-
ref: main
38-
submodules: recursive
18+
19+
- name: Get package version
20+
id: get_pkg_version
21+
run: echo "pkg_version=$(cat package.json | jq -r .version)" >> "$GITHUB_OUTPUT"
22+
23+
- name: Get npm version
24+
id: get_npm_version
25+
run: echo "npm_version=$(npm view java-slang version)" >> "$GITHUB_OUTPUT"
26+
27+
- name: Stop if version has not changed
28+
if: steps.get_pkg_version.outputs.pkg_version == steps.get_npm_version.outputs.npm_version
29+
run: exit 1
30+
3931
- name: Setup Node.js
4032
uses: actions/setup-node@v4
4133
with:
4234
node-version: 20
35+
4336
- name: Install dependencies
4437
run: yarn install --frozen-lockfile
38+
4539
- name: Build
4640
run: yarn build
41+
4742
- name: Publish to npm
4843
run: npm publish
4944
env:

0 commit comments

Comments
 (0)