Skip to content

Commit f75bdfc

Browse files
committed
ci: deploy to npm instead of github packages
Targets the public npm registry instead of the private github packages to make this as easy to consume as possible. Drop the dependency on a third party action for tagging, it's only a few lines to add a tag, and the action was broken. Going with one less dependency to keep up with.
1 parent c746cd1 commit f75bdfc

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish reference lib package to GitHub Packages
1+
name: Publish reference lib package to NPM
22
on:
33
push:
44
branches: ['main']
@@ -12,36 +12,31 @@ defaults:
1212
working-directory: ./reference-lib
1313
shell: bash
1414

15-
1615
jobs:
1716
build:
1817
runs-on: ubuntu-latest
19-
permissions:
20-
contents: read
21-
packages: write
2218
steps:
2319
- uses: actions/checkout@v4
2420
- uses: actions/setup-node@v4
2521
with:
2622
node-version: '16.x'
27-
registry-url: 'https://npm.pkg.github.com'
28-
scope: '@nginxinc'
23+
registry-url: 'https://registry.npmjs.org'
2924
- name: Install dependencies
3025
run: npm ci
3126
- name: Test it out
3227
run: npm run test
3328
- name: Bundle using rollup
3429
run: npm run build
35-
- name: get package-version
36-
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
3730
- name: publish package
3831
if: github.event_name == 'push'
3932
run: npm publish
4033
env:
41-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
- name: Create and push tag
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35+
- name: Create and push tag matching the npm package
4336
if: github.event_name == 'push'
44-
uses: mathieudutour/[email protected]
45-
with:
46-
github_token: ${{ secrets.GITHUB_TOKEN }}
47-
custom_tag: ${{ env.PACKAGE_VERSION }}
37+
run: |
38+
export PACKAGE_VERSION=v$(node -p -e 'require("./package.json").version')
39+
git config --global user.name 'github-actions[bot]'
40+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
41+
git tag -a "$PACKAGE_VERSION" -m "Release $PACKAGE_VERSION"
42+
git push origin "$PACKAGE_VERSION"

reference-lib/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
"main": "dist/index.js",
66
"type": "module",
77
"scripts": {
8-
"build": "./node_modules/.bin/rollup -c",
8+
"build": "rollup -c",
99
"test": "jest --coverage"
1010
},
1111
"repository": {
1212
"type": "git",
13-
"url": "https://github.com/nginxinc/nginx-directive-reference.git"
13+
"url": "git+https://github.com/nginx/nginx-directive-reference.git"
1414
},
1515
"devDependencies": {
1616
"@rollup/plugin-json": "^6.1.0",
@@ -22,5 +22,8 @@
2222
},
2323
"files": [
2424
"dist/**/*"
25-
]
25+
],
26+
"publishConfig": {
27+
"access": "public"
28+
}
2629
}

0 commit comments

Comments
 (0)