Skip to content

Commit

Permalink
add test action and update publish scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Aug 13, 2023
1 parent cd83b72 commit 3fd6b68
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-npm-on-new-release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish to npm and GitHub
name: Publish (NPM & GPR)

on:
release:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: test

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./packages/nextjs-themes
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
- run: npm i -g pnpm && pnpm i --filter nextjs-themes
name: Install dependencies
- name: Test
run: npm test
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8 changes: 8 additions & 0 deletions packages/nextjs-themes/createPackageJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ packageJson.main = "index.js";
packageJson.types = "index.d.ts";

fs.writeFileSync(path.resolve(__dirname, "dist", "package.json"), JSON.stringify(packageJson, null, 2));

const readMePath = path.resolve(__dirname, "dist", "README.md");
let readMe = fs.readFileSync(readMePath, { encoding: "utf8" });
readMe.replace(
"[![Publish to npm and GitHub](https://github.com/mayank1513/nextjs-themes/actions/workflows/publish-to-npm-on-new-release.yml/badge.svg)](https://github.com/mayank1513/nextjs-themes/actions/workflows/publish-to-npm-on-new-release.yml)",
"",
);
fs.writeFileSync(readMePath, readMe);
4 changes: 2 additions & 2 deletions packages/nextjs-themes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"build": "tsup src --dts",
"build:fast": "tsup src",
"dev": "pnpm build:fast --watch",
"publish-package": "node createPackageJSON.js && cp ../../README.md dist/README.md && cd dist && npm publish && cd ..",
"publish-package": "cp ../../README.md dist && node createPackageJSON.js && cd dist && npm publish && cd ..",
"publish-package2": "node seo.js && cd dist && npm publish && cd ..",
"publish-gpr": "node prepGPR.js && cp ../../README.md dist/README.md && cd dist && npm publish && cd ..",
"publish-gpr": "cp ../../README.md dist && node prepGPR.js && cd dist && npm publish && cd ..",
"publish-gpr2": "node seo.js && cd dist && npm publish",
"test": "vitest run --coverage"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/nextjs-themes/prepGPR.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ packageJson.publishConfig = {
};

fs.writeFileSync(path.resolve(__dirname, "dist", "package.json"), JSON.stringify(packageJson, null, 2));

const readMePath = path.resolve(__dirname, "dist", "README.md");
let readMe = fs.readFileSync(readMePath, { encoding: "utf8" });
readMe.replace(
"[![Publish to npm and GitHub](https://github.com/mayank1513/nextjs-themes/actions/workflows/publish-to-npm-on-new-release.yml/badge.svg)](https://github.com/mayank1513/nextjs-themes/actions/workflows/publish-to-npm-on-new-release.yml)",
"",
);
fs.writeFileSync(readMePath, readMe);

0 comments on commit 3fd6b68

Please sign in to comment.