Skip to content

Commit 8e56cd5

Browse files
committed
Simplify npm publish workflow
1 parent 901965d commit 8e56cd5

1 file changed

Lines changed: 2 additions & 85 deletions

File tree

.github/workflows/publish.yml

Lines changed: 2 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,8 @@ jobs:
3232
id: publish_status
3333
uses: tehpsalmist/npm-publish-status-action@01cb25946b194a7a5468f22c8e74db04c283f121
3434

35-
- name: report npm package version status
36-
run: |
37-
package_name="$(node -p "require('./package.json').name")"
38-
package_version="$(node -p "require('./package.json').version")"
39-
40-
if [ "${{ steps.publish_status.outputs.exists }}" = "1" ]; then
41-
echo "${package_name}@${package_version} is already published; exiting without publishing."
42-
elif [ "${{ steps.publish_status.outputs.exists }}" = "0" ]; then
43-
echo "${package_name}@${package_version} is not published yet; continuing."
44-
else
45-
echo "::error::Unexpected npm publish status: ${{ steps.publish_status.outputs.exists }}"
46-
exit 1
47-
fi
48-
49-
verify:
50-
name: verify package
35+
publish:
36+
name: publish to npmjs
5137
needs: check
5238
if: needs.check.outputs.should_publish == 'true'
5339
runs-on: ubuntu-latest
@@ -66,68 +52,6 @@ jobs:
6652
- name: install dependencies
6753
run: npm ci
6854

69-
- name: run tests
70-
run: npm test
71-
72-
- name: audit dependencies
73-
run: npm audit --audit-level=moderate
74-
75-
- name: verify runtime dependency tree
76-
run: npm ls --omit=dev --all
77-
78-
prepublish_check:
79-
name: check npm package version before publish
80-
needs: verify
81-
if: github.event.release.prerelease == false
82-
runs-on: ubuntu-latest
83-
outputs:
84-
should_publish: ${{ steps.publish_status.outputs.exists == '0' }}
85-
86-
steps:
87-
- name: checkout
88-
uses: actions/checkout@v6
89-
90-
- name: setup node 24
91-
uses: actions/setup-node@v6
92-
with:
93-
node-version: 24
94-
registry-url: https://registry.npmjs.org
95-
96-
- name: check npm package version
97-
id: publish_status
98-
uses: tehpsalmist/npm-publish-status-action@01cb25946b194a7a5468f22c8e74db04c283f121
99-
100-
- name: report npm package version status
101-
run: |
102-
package_name="$(node -p "require('./package.json').name")"
103-
package_version="$(node -p "require('./package.json').version")"
104-
105-
if [ "${{ steps.publish_status.outputs.exists }}" = "1" ]; then
106-
echo "${package_name}@${package_version} was published while this workflow was verifying; exiting without publishing."
107-
elif [ "${{ steps.publish_status.outputs.exists }}" = "0" ]; then
108-
echo "${package_name}@${package_version} is still not published; continuing."
109-
else
110-
echo "::error::Unexpected npm publish status: ${{ steps.publish_status.outputs.exists }}"
111-
exit 1
112-
fi
113-
114-
publish:
115-
name: publish to npmjs
116-
needs: prepublish_check
117-
if: needs.prepublish_check.outputs.should_publish == 'true'
118-
runs-on: ubuntu-latest
119-
120-
steps:
121-
- name: checkout
122-
uses: actions/checkout@v6
123-
124-
- name: setup node 24
125-
uses: actions/setup-node@v6
126-
with:
127-
node-version: 24
128-
registry-url: https://registry.npmjs.org
129-
cache: npm
130-
13155
- name: pack package
13256
id: pack
13357
run: |
@@ -142,13 +66,6 @@ jobs:
14266
with:
14367
subject-path: ${{ steps.pack.outputs.tarball }}
14468

145-
- name: upload npm package artifact
146-
uses: actions/upload-artifact@v4
147-
with:
148-
name: npm-package
149-
path: ${{ steps.pack.outputs.tarball }}
150-
if-no-files-found: error
151-
15269
- name: publish package
15370
run: npm publish "$TARBALL" --provenance --access public
15471
env:

0 commit comments

Comments
 (0)