diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c652f68..79751f0b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,38 +2,39 @@ name: Release on: push: - tags: - - 'v*' + branches: [main, master] permissions: contents: write + id-token: write jobs: - build: + release: + name: Semantic Release runs-on: ubuntu-latest + concurrency: release steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-python@v5 with: python-version: "3.12" - - run: pip install build - - run: python -m build - - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist/ + cache: "pip" - release: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/download-artifact@v4 + - name: Install dependencies + run: pip install python-semantic-release build + + - name: Python Semantic Release + id: release + uses: python-semantic-release/python-semantic-release@v9 with: - name: dist - path: dist/ - - name: Create GitHub Release - uses: softprops/action-gh-release@v2 + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish to PyPI + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 with: - files: dist/* - generate_release_notes: true + password: ${{ secrets.PYPI_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index d7eb86b1..977863a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,3 +118,32 @@ exclude = ["tests"] [[tool.mypy.overrides]] module = ["tests.*"] ignore_errors = true + +[tool.semantic_release] +version_toml = ["pyproject.toml:project.version"] +branch = "major" +build_command = "pip install build && python -m build" + +[tool.semantic_release.changelog] +changelog_file = "CHANGELOG.md" +exclude_commits = ["^chore\\(deps\\)"] + +[[tool.semantic_release.changelog.categories]] +title = "Features" +match = "feat" + +[[tool.semantic_release.changelog.categories]] +title = "Bug Fixes" +match = "fix" + +[[tool.semantic_release.changelog.categories]] +title = "Breaking Changes" +match = "break" + +[[tool.semantic_release.changelog.categories]] +title = "Documentation" +match = "docs" + +[[tool.semantic_release.changelog.categories]] +title = "Other" +match = ".*"