From 568b21ab03c6dc9d2a4109e7a8c1f96320cc2b2b Mon Sep 17 00:00:00 2001 From: suhaotian Date: Tue, 20 Feb 2024 13:01:18 +1100 Subject: [PATCH] add actions --- .github/workflows/check.yml | 29 +++++++++++++++++++++ .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ package.json | 5 ++-- 3 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..a29b5f4 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,29 @@ +name: Code Check +on: push + +jobs: + check: + name: Code check + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: 18.x + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install dependencies + run: pnpm install + + - name: Check type + run: pnpm checktype + + - name: Run tests + run: pnpm test diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..04a94c6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + branches: + - main + tags: + - v* + pull_request: + +jobs: + release: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + if: startsWith(github.ref, 'refs/tags/v') + permissions: + id-token: write + steps: + - name: Check out + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + registry-url: 'https://registry.npmjs.org' + + - uses: pnpm/action-setup@v2 + name: Install pnpm + id: pnpm-install + with: + version: 8 + run_install: false + + - name: Install dependencies + run: pnpm install + + - name: Check types + run: pnpm checktype + + - name: Release + run: pnpm start-publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} diff --git a/package.json b/package.json index b7bad49..4f76687 100644 --- a/package.json +++ b/package.json @@ -18,9 +18,10 @@ "build": "npm run build:lib && bunchee ./src/index.ts -m", "build:lib": "rm -rf lib && tsc --project tsconfig.json", "test": "pnpm build:lib && node --test", - "prepare": "is-ci || pnpm build && husky", + "checktype": "tsc --noEmit", "start-publish": "pnpm test && npm publish --registry=https://registry.npmjs.org", - "push": "git lfs push --all origin" + "push": "git push && git lfs push --all origin", + "prepare": "is-ci || pnpm build && husky" }, "dependencies": { "ts-deepmerge": "^7.0.0"