diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..aa72f59 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,82 @@ +name: Publish to npm + +on: + push: + tags: + - 'v*.*.*' + +permissions: + contents: write + id-token: write + +jobs: + ci: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: TypeScript type checking + run: npm run type-check + + - name: Lint + run: npm run lint + + - name: Format check + run: npm run format:check + + - name: Run tests + env: + CI: true + NODE_ENV: test + run: npm test + + - name: Build package + run: npm run build + + publish: + needs: ci + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build + + - name: Publish to npm + run: npm publish --provenance --access public + + release: + needs: publish + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true