Skip to content

ci: deploy to npm instead of github packages #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions .github/workflows/reference-lib.publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish reference lib package to GitHub Packages
name: Publish reference lib package to NPM
on:
push:
branches: ['main']
Expand All @@ -12,36 +12,31 @@ defaults:
working-directory: ./reference-lib
shell: bash


jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
registry-url: 'https://npm.pkg.github.com'
scope: '@nginxinc'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Test it out
run: npm run test
- name: Bundle using rollup
run: npm run build
- name: get package-version
run: node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV
- name: publish package
if: github.event_name == 'push'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push tag
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create and push tag matching the npm package
if: github.event_name == 'push'
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ env.PACKAGE_VERSION }}
run: |
export PACKAGE_VERSION=v$(node -p -e 'require("./package.json").version')
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git tag -a "$PACKAGE_VERSION" -m "Release $PACKAGE_VERSION"
git push origin "$PACKAGE_VERSION"
9 changes: 6 additions & 3 deletions reference-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "./node_modules/.bin/rollup -c",
"build": "rollup -c",
"test": "jest --coverage"
},
"repository": {
"type": "git",
"url": "https://github.com/nginxinc/nginx-directive-reference.git"
"url": "git+https://github.com/nginx/nginx-directive-reference.git"
},
"devDependencies": {
"@rollup/plugin-json": "^6.1.0",
Expand All @@ -22,5 +22,8 @@
},
"files": [
"dist/**/*"
]
],
"publishConfig": {
"access": "public"
}
}