diff --git a/.github/workflows/npm_deploy.yml b/.github/workflows/npm_deploy.yml index 27f84b3..952409d 100644 --- a/.github/workflows/npm_deploy.yml +++ b/.github/workflows/npm_deploy.yml @@ -1,22 +1,40 @@ name: NPM Publish - on: - release: - types: [created] + push: + branches: + - main jobs: publish: + name: Publish runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout + uses: actions/checkout@v5 with: - node-version: 18 - - name: Install Node types - run: npm install @types/node - - name: Run build - run: npm run build - - name: Publish package - uses: JS-DevTools/npm-publish@v1 + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Node.js + uses: actions/setup-node@v5 with: - token: ${{ secrets.NPM }} + node-version: "lts/*" + registry-url: "https://registry.npmjs.org" + - name: Install dependencies + run: npm ci + - name: Publish to NPM and Create GitHub Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + npx -p semantic-release \ + -p @semantic-release/changelog \ + -p @semantic-release/git \ + -p @semantic-release/github \ + -p @semantic-release/npm \ + -p conventional-changelog-conventionalcommits \ + semantic-release diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..e4aa465 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,75 @@ +{ + "branches": ["main"], + "tagFormat": "${version}", + "plugins": [ + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "writerOpts": { + "types": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "docs", + "section": "Documentation", + "hidden": false + }, + { + "type": "deps", + "section": "Dependency Updates", + "hidden": false + }, + { + "type": "chore", + "hidden": true + }, + { + "type": "style", + "hidden": true + }, + { + "type": "refactor", + "hidden": true + }, + { + "type": "perf", + "hidden": true + }, + { + "type": "test", + "hidden": true + } + ] + } + } + ], + [ + "@semantic-release/changelog", + { + "changelogFile": "CHANGELOG.md", + "changelogTitle": "# Changelog" + } + ], + [ + "@semantic-release/npm", + { + "pkgRoot": "." + } + ], + [ + "@semantic-release/git", + { + "assets": ["dist/**", "package.json", "CHANGELOG.md"], + "message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes} [skip ci]" + } + ], + "@semantic-release/github" + ] +}