diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7cb71f5..5c4989b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,9 +10,9 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: python-version: "3.12" diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml new file mode 100644 index 0000000..b178665 --- /dev/null +++ b/.github/workflows/pr-title.yml @@ -0,0 +1,17 @@ +name: PR title + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +permissions: + pull-requests: read + +jobs: + conventional: + runs-on: ubuntu-latest + steps: + - name: Check PR title follows Conventional Commits + uses: amannn/action-semantic-pull-request@v6 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7e55c7..bdb5129 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,9 +10,9 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v7 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v7 with: python-version: "3.12" @@ -24,3 +24,8 @@ jobs: - name: Pytest run: pytest + + - name: Build + run: | + pip install build + python -m build diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..4243175 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,71 @@ +name: Release + +on: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: release + cancel-in-progress: false + +jobs: + release: + runs-on: ubuntu-latest + environment: pypi + permissions: + contents: write + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + ref: ${{ github.ref_name }} + fetch-depth: 0 + + - name: Reset to the workflow commit + run: git reset --hard ${{ github.sha }} + + - name: Setup Python + uses: actions/setup-python@v7 + with: + python-version: "3.12" + + - name: Install dependencies + run: pip install -e ".[dev]" httpx types-jsonschema + + - name: Ruff + run: ruff check . + + - name: Mypy + run: mypy . + + - name: Generate types + run: python -m decodo.codegen.codegen + + - name: Pytest + run: pytest + + - name: Release + id: release + uses: python-semantic-release/python-semantic-release@v10.7.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + commit: "false" + changelog: "false" + + - name: Build + if: steps.release.outputs.released == 'true' + run: | + pip install build + python -m build + + - name: Publish to PyPI + if: steps.release.outputs.released == 'true' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist/ diff --git a/.github/workflows/worklfow.yml b/.github/workflows/worklfow.yml deleted file mode 100644 index 7b1f677..0000000 --- a/.github/workflows/worklfow.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Publish Python SDK to PyPI - -on: - push: - branches: - - main - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - environment: pypi - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Generate types - run: | - pip install httpx pydantic jsonschema - pip install -e . - python -m decodo.codegen.codegen - - - name: Build - run: | - pip install build - python -m build - - - name: Publish - uses: pypa/gh-action-pypi-publish@release/v1 - with: - packages-dir: dist/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5035fe9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,10 @@ +# Contributing + +## Releases + +Releases are automated with python-semantic-release. Merging to `main` publishes a new +PyPI version based on the PR title, which must follow +[Conventional Commits](https://www.conventionalcommits.org) (a CI check enforces it): +`fix:` → patch, `feat:` → minor, `feat!:` or a `BREAKING CHANGE:` footer → major. +`chore:`, `docs:`, `ci:`, `refactor:`, `test:` don't release. Don't edit `version` in +`pyproject.toml`; the release job sets it at publish time. diff --git a/pyproject.toml b/pyproject.toml index 346d140..026ec5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "decodo-sdk" -version = "2.4.0" +version = "0.0.0" description = "Official Python SDK for the Decodo APIs" readme = "README.md" license = { file = "LICENSE" } @@ -65,3 +65,9 @@ ignore_errors = true [tool.pytest.ini_options] testpaths = ["tests"] +[tool.semantic_release] +version_toml = ["pyproject.toml:project.version"] +commit_parser = "conventional" + +[tool.semantic_release.branches.main] +match = "main"