Skip to content

Commit 2e4ca51

Browse files
committed
feat: allow publishing to npm
1 parent 01432f6 commit 2e4ca51

File tree

9 files changed

+441
-6
lines changed

9 files changed

+441
-6
lines changed

.github/workflows/npm-publish.yml

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish country-config to npm
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v2
18+
with:
19+
node-version: "16"
20+
registry-url: "https://registry.npmjs.org/"
21+
22+
- name: Install dependencies
23+
run: yarn install
24+
working-directory: packages/country-config
25+
26+
- name: Build
27+
run: yarn build
28+
working-directory: packages/country-config
29+
30+
- name: Check if version exists on npm
31+
id: check-version
32+
run: |
33+
PACKAGE_VERSION=$(node -p "require('./packages/country-config/package.json').version")
34+
if npm view @opencrvs/mosip@$PACKAGE_VERSION > /dev/null 2>&1; then
35+
echo "Version $PACKAGE_VERSION already exists on npm."
36+
exit 0
37+
else
38+
echo "Version $PACKAGE_VERSION does not exist on npm."
39+
fi
40+
working-directory: packages/country-config
41+
42+
- name: Publish to npm
43+
if: steps.check-version.outputs.version-exists == 'false'
44+
run: npm publish
45+
working-directory: packages/country-config
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/country-config/.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!build

packages/country-config/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@opencrvs-mosip/country-config",
3-
"version": "1.0.0",
2+
"name": "@opencrvs/mosip",
3+
"version": "1.7.0-alpha.1",
44
"license": "MPL-2.0",
55
"main": "./build/index.js",
66
"exports": {

packages/country-config/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from "./form-definitions";
1+
export * from "./forms";
22
export * from "./events";

0 commit comments

Comments
 (0)