Skip to content

Commit

Permalink
Publish web component to npm
Browse files Browse the repository at this point in the history
  • Loading branch information
danim1130 committed Oct 31, 2024
1 parent 0f7540f commit 77e95e2
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Create Node.js Package

"on":
push:
branches:
- "prod"
- "main"
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.16.1"
- run: npm i
- run: npm run test
build:
needs: unit-tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18.16.1"
- name: Create public env file
run: |
echo $(git log -5)
touch .env
echo PUBLIC_COMMIT_HASH=$(git log --format="%h" -n 1) >> .env
echo PUBLIC_APP_ENV=production >> .env
echo PUBLIC_GOOGLE_CLIENT_ID=${{ secrets.PUBLIC_GOOGLE_CLIENT_ID_PROD }} >> .env
echo PUBLIC_CREATION_DATE=$(git log --format="%cd" --date=format:'%Y-%m-%d' -1) >> .env
- run: npm ci && npm run build:webcomponent
env:
WEB_COMPONENT_NAME: profile-cloud-offline
- run: cd ./npm-package && npm version $(date +1.%Y%m%d.%-H%M) --no-git-tag-version
- run: cd ./npm-package && npm i && npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
6 changes: 6 additions & 0 deletions npm-package/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@intechstudio/profile-cloud-webcomponent",
"version": "0.0.1",
"type": "module",
"main": "dist/components.js"
}
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"type": "module",
"dependencies": {
"@intechstudio/grid-protocol": "1.20240916.1230",
"@intechstudio/grid-protocol": "1.20241030.1609",
"@intechstudio/grid-uikit": "1.20241017.2206",
"@melt-ui/svelte": "^0.83.0",
"@toast-ui/editor": "^3.2.2",
Expand Down
5 changes: 4 additions & 1 deletion vite.config.webcomponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export default defineConfig({
name: "<<name>>",
fileName: "components"
},
outDir: "public/wc"
outDir:
process.env.WEB_COMPONENT_NAME == "profile-cloud-offline"
? "npm-package/dist"
: "public/wc"
},
envPrefix: "PUBLIC_"
});

0 comments on commit 77e95e2

Please sign in to comment.