Skip to content

Commit

Permalink
chore: setup github actions workflow, sematic release config, husky c…
Browse files Browse the repository at this point in the history
…onfig, and test js file
  • Loading branch information
Dan-Y-Ko committed Jan 15, 2025
1 parent 0261e9f commit c03ab6b
Show file tree
Hide file tree
Showing 13 changed files with 3,566 additions and 23 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: "pnpm"

- name: Install dependencies
run: pnpm install

- name: Authenticate with npm
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2 changes: 2 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
npx commitlint --edit "$1"
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
pnpm build
node generate-exports.js
17 changes: 17 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/github",
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": ["package.json", "CHANGELOG.md"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}
]
]
}
3 changes: 3 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["@commitlint/config-conventional"],
};
29 changes: 29 additions & 0 deletions generate-exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import fs from "fs";
import path from "path";

const distPath = "./dist";

const components = fs.readdirSync(distPath).filter((file) => {
return fs.statSync(path.join(distPath, file)).isDirectory();
});

const exportsObject = {
".": {
import: "./dist/index.js",
types: "./dist/types/index.d.ts",
},
};

components.forEach((component) => {
exportsObject[`./${component}`] = {
import: `./dist/${component}/index.js`,
types: `./dist/types/${component}/index.d.ts`,
};
});

const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
packageJson.exports = exportsObject;

fs.writeFileSync("./package.json", JSON.stringify(packageJson, null, 2));

console.log("exports field generated and saved to package.json");
38 changes: 34 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
{
"name": "chingu-modules",
"private": true,
"name": "@chingu-x/modules",
"description": "Module with all of the business logic in Chingu dashboard projects",
"version": "0.0.0",
"type": "module",
"module": "dist/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist"
],
"license": "GPL-3.0",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"build": "vite build && tsc",
"preview": "vite preview",
"prepublishOnly": "pnpm build",
"prepare": "husky install"
},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"@semantic-release/npm": "^12.0.1",
"husky": "^9.1.7",
"semantic-release": "^24.2.1",
"typescript": "~5.6.2",
"vite": "^6.0.5"
},
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/types/index.d.ts"
},
"./test": {
"import": "./dist/test/index.js",
"types": "./dist/types/test/index.d.ts"
},
"./types": {
"import": "./dist/types/index.js",
"types": "./dist/types/types/index.d.ts"
}
}
}
Loading

0 comments on commit c03ab6b

Please sign in to comment.