Skip to content

Commit 516e70f

Browse files
committed
chore(PLAT-2937) - Add publish.yml workflow using Trusted Provider
1 parent bb5954d commit 516e70f

File tree

5 files changed

+66
-18
lines changed

5 files changed

+66
-18
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
node-version: [18, 20]
15+
node-version: [20, 22, 24]
1616

1717
services:
1818
redis:
@@ -35,6 +35,9 @@ jobs:
3535
with:
3636
node-version: ${{ matrix.node }}
3737

38+
- name: Upgrade npm to v11
39+
run: npm install -g npm@11
40+
3841
- name: Install dependencies
3942
run: npm install
4043

.github/workflows/publish.yml

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
1-
name: "Publish to npm"
1+
name: NPM Publish
22

33
on:
4-
release:
5-
types: [created]
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
type: choice
8+
description: Version type
9+
required: true
10+
options:
11+
- "patch"
12+
- "minor"
13+
- "major"
14+
default: "patch"
615

716
jobs:
817
publish:
9-
name: Publish release to npm
1018
runs-on: ubuntu-latest
11-
19+
permissions:
20+
id-token: write # Required for publishing using OIDC authentication
21+
contents: write
1222
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
23+
- uses: actions/checkout@v4
1524

16-
- name: Use Node
25+
- name: Setup Node
1726
uses: actions/setup-node@v4
1827
with:
1928
node-version-file: '.node-version'
29+
cache: 'npm'
30+
31+
- name: Upgrade npm to v11
32+
run: npm install -g npm@11
2033

2134
- name: Install dependencies
2235
run: npm install
2336

24-
- name: publish to npm
25-
id: publish
26-
uses: JS-DevTools/npm-publish@v3
27-
with:
28-
token: ${{ secrets.NPM_TOKEN }}
37+
- name: Run tests and linter
38+
run: npm test
39+
40+
- name: Enforce coverage
41+
run: npm run enforce
42+
43+
- name: Configure Git
44+
run: |
45+
git config --global user.email "no-reply@lob.com"
46+
git config --global user.name "NPM Publish Action"
47+
48+
- name: Generate changelog
49+
run: npm run changelog:${{ github.event.inputs.version }}
50+
51+
- name: Commit changelog
52+
run: npm run version:commit
53+
54+
- name: Bump version
55+
run: npm version "${{ github.event.inputs.version }}"
2956

57+
- name: Publish package
58+
uses: JS-DevTools/npm-publish@v4
3059

60+
- name: Push changes to Github
61+
run: git push --follow-tags

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.15.0
1+
20.17.0

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"lint": "eslint .",
99
"test": "nyc _mocha test --exit --require test/setup.js --recursive --timeout 30000",
1010
"test:raw": "mocha test --require test/setup.js --recursive --timeout 30000",
11-
"release:major": "changelog -M && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version major && git push origin && git push origin --tags",
12-
"release:minor": "changelog -m && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version minor && git push origin && git push origin --tags",
13-
"release:patch": "changelog -p && git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md' && npm version patch && git push origin && git push origin --tags"
11+
"changelog:patch": "changelog -p",
12+
"changelog:minor": "changelog -m",
13+
"changelog:major": "changelog -M",
14+
"version:commit": "git add CHANGELOG.md && git commit -m 'updated CHANGELOG.md'"
1415
},
1516
"repository": {
1617
"type": "git",
@@ -27,6 +28,10 @@
2728
"url": "https://github.com/lob/hapi-bookshelf-total-count/issues"
2829
},
2930
"homepage": "https://github.com/lob/hapi-bookshelf-total-count#readme",
31+
"engines": {
32+
"node": ">=20.17.0",
33+
"npm": ">=11.5.1"
34+
},
3035
"peerDependencies": {
3136
"@hapi/hapi": "^21.3.10",
3237
"bookshelf": ">=1.2.0",

0 commit comments

Comments
 (0)