Skip to content

Commit

Permalink
feat: add ability to publish as npm module
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad-tkachenko committed Nov 5, 2023
1 parent 0f2c7d3 commit 85e5e69
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish NPM Package

on:
push:
tags:
- '*.*.*'

jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Extract git tag name
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}

- run: yarn install
- run: yarn build

- name: Update package.json version based on a tag
run: |
node -e " \
const package =JSON.parse(fs.readFileSync('package.json', 'utf8'));
package.version = '$RELEASE_VERSION'; \
fs.writeFileSync('package.json', JSON.stringify(package)); \
"
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

!/.nvmrc

!/.npmignore

!/bin
!/bin/**

Expand Down
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ignore all
*

!dist/src/**/*.js
!dist/src/**/*.js.map
!dist/src/**/*.d.ts
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_TAG=18.17.0-alpine
ARG NODE_TAG=20.9.0-alpine

# prepare dev dependencies
FROM node:${NODE_TAG} as DEV_DEPENDENCIES
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"authentication",
"authorization"
],
"bin": {
"prxi-openid-connect": "dist/src/index.js"
},
"scripts": {
"start": "node dist/src/index.js | rotate-logs",
"pino-pretty": "pino-pretty",
Expand Down Expand Up @@ -84,7 +87,7 @@
"dependencies": {
"@vrbo/pino-rotating-file": "^4.4.0",
"cookie": "^0.5.0",
"dotenv": "^16.2.0",
"dotenv": "^16.3.1",
"jsonwebtoken": "^9.0.1",
"jwk-to-pem": "^2.0.5",
"node-graceful-shutdown": "^1.1.5",
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import { Prxi } from "prxi";
import getLogger from "./Logger";
import { start } from "./Server";
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1101,10 +1101,10 @@ diff@^5.0.0:
resolved "https://registry.yarnpkg.com/diff/-/diff-5.1.0.tgz#bc52d298c5ea8df9194800224445ed43ffc87e40"
integrity sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==

dotenv@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.2.0.tgz#d0c7110551d39c407f407d1afdce49c501c8e320"
integrity sha512-jcq2vR1DY1+QA+vH58RIrWLDZOifTGmyQJWzP9arDUbgZcySdzuBb1WvhWZzZtiXgfm+GW2pjBqStqlfpzq7wQ==
dotenv@^16.3.1:
version "16.3.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.3.1.tgz#369034de7d7e5b120972693352a3bf112172cc3e"
integrity sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==

duplexer@~0.1.1:
version "0.1.2"
Expand Down

0 comments on commit 85e5e69

Please sign in to comment.