diff --git a/.github/workflows/main-deploy.yml b/.github/workflows/main-deploy.yml new file mode 100644 index 0000000..ed5771e --- /dev/null +++ b/.github/workflows/main-deploy.yml @@ -0,0 +1,55 @@ +name: Main Deploy + +on: + push: + branches: + - main + +jobs: + release: + name: Lint, Test, and Deploy + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Set Up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + + - name: Install Dependencies + run: npm ci + + - name: Lint Code + run: npm run lint + + - name: Run Tests + run: npm run test:ci + + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + fail_ci_if_error: true + + - name: Build Artifacts + run: npm run build + + - name: Save Build Artifacts + uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + - name: Run Semantic Release + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml new file mode 100644 index 0000000..9d788e7 --- /dev/null +++ b/.github/workflows/pr-tests.yml @@ -0,0 +1,40 @@ +name: PR Tests + +on: + pull_request: + branches: + - main + +jobs: + test: + name: Run Lint, Tests, and Code Coverage + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Set Up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + + - name: Install Dependencies + run: npm ci + + - name: Lint Code + run: npm run lint + + - name: Run Tests + run: npm run test:ci + + - name: Build Artifacts + run: npm run build + + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + flags: unittests + fail_ci_if_error: true diff --git a/package.json b/package.json index ff2dc13..da86a96 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "main": "index.js", "scripts": { "build": "vite build", + "build:map": "vite build --sourcemap", "lint": "eslint 'src/**/*.{ts,tsx}'", "format": "prettier --write 'src/**/*.{ts,tsx}'", "test": "vitest run", "test:ci": "vitest run --coverage", - "test:watch": "vitest src", - "prepare": "husky" + "test:watch": "vitest src" }, "keywords": [ "react", @@ -24,6 +24,17 @@ "README.md", "LICENSE" ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/click-edit.es.js", + "require": "./dist/click-edit.umd.js" + }, + "./dist/style.css": { + "import": "./dist/react-click-edit.css", + "require": "./dist/react-click-edit.css" + } + }, "author": "", "license": "MIT", "peerDependencies": { diff --git a/vite.config.ts b/vite.config.ts index b1c45ad..83a03a4 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,12 +19,11 @@ export default defineConfig({ }, }, build: { - sourcemap: true, lib: { entry: resolve(__dirname, "src/index.ts"), name: "ReactClickToEdit", formats: ["es", "umd"], - fileName: format => `click-to-edit.${format}.js`, + fileName: (format) => `click-edit.${format}.js`, }, rollupOptions: { external: ["react", "react-dom", "react/jsx-runtime", "classnames"],