Skip to content

Commit 78e7811

Browse files
ci: Automatically publish to npm after adding a release (#87)
Co-authored-by: Josh Mock <[email protected]>
1 parent 6979b17 commit 78e7811

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

.github/workflows/npm-publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Publish package to npm
1+
name: Publish package to npm (manual)
22
on:
33
workflow_dispatch:
44
inputs:
55
branch:
6-
description: 'Git branch to build and publish'
6+
description: "Git branch to build and publish"
77
required: true
88
default: main
99
jobs:
@@ -16,10 +16,10 @@ jobs:
1616
- uses: actions/checkout@v4
1717
with:
1818
ref: ${{ github.event.inputs.branch }}
19-
- uses: actions/setup-node@v3
19+
- uses: actions/setup-node@v4
2020
with:
21-
node-version: '20.x'
22-
registry-url: 'https://registry.npmjs.org'
21+
node-version: "22.x"
22+
registry-url: "https://registry.npmjs.org"
2323
- run: npm install -g npm
2424
- run: npm install
2525
- run: npm test

.github/workflows/release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ jobs:
2020
package-name: "@elastic/elasticsearch-serverless"
2121
bootstrap-sha: "e71b2ff05abf70702e9342378da571032e670c8c"
2222
token: ${{ secrets.TOKEN_RELEASE_PLEASE }}
23+
24+
publish:
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
id-token: write
29+
needs: [release-please]
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: main
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: "22.x"
37+
registry-url: "https://registry.npmjs.org"
38+
- run: npm install -g npm
39+
- run: npm install
40+
- run: npm test
41+
- run: npm publish --provenance --access public
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)