diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..be5cb00 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,46 @@ +# .github/workflows/publish.yml +name: Publish Package to npm on Tag + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # vX.Y.Z 형식의 태그가 푸시될 때 실행 + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read # 코드를 읽기만 하면 됨 + id-token: write # npm 인증을 위해 필요할 수 있음 + steps: + - name: Checkout code + uses: actions/checkout@v4 + # 자동으로 트리거된 태그의 코드를 가져옴 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" # 사용할 Node.js 버전 + registry-url: "https://registry.npmjs.org/" + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 8 + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Run tests + run: pnpm test + + - name: Build package + run: pnpm run build + + - name: Package preview (dry-run) + run: pnpm run pack:preview + + - name: Publish package to npm + run: pnpm publish --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_GRANULAR_TOKEN }} diff --git a/package.json b/package.json index 0ba0762..174968a 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,10 @@ "analyze:bundle": "echo 'Bundle Analysis:' && du -h dist/bundle/* && echo '\\nGzipped sizes:' && gzip -c dist/bundle/kr-corekit.js | wc -c | awk '{print \"ESM: \" $1/1024 \" KB\"}' && gzip -c dist/bundle/kr-corekit.cjs | wc -c | awk '{print \"CJS: \" $1/1024 \" KB\"}'", "pack:preview": "npm pack --dry-run", "test": "vitest", - "coverage": "vitest run --coverage" + "coverage": "vitest run --coverage", + "release:patch": "pnpm version patch && git push origin main --follow-tags", + "release:minor": "pnpm version minor && git push origin main --follow-tags", + "release:major": "pnpm version major && git push origin main --follow-tags" }, "repository": { "type": "git",