Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: CI

on:
push:
pull_request:

jobs:
Expand Down Expand Up @@ -31,23 +30,3 @@ jobs:

- name: Test
run: uv run pytest tests/ -v --cov=ddogctl --cov-report=xml

publish:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/v')
permissions:
id-token: write
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: "3.12"

- name: Build package
run: uv build

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
30 changes: 0 additions & 30 deletions .github/workflows/publish.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Release

on:
push:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
enable-cache: true

- name: Install dependencies
run: uv sync --all-extras

- name: Check formatting
run: uv run black --check ddogctl/ tests/

- name: Lint
run: uv run ruff check ddogctl/ tests/

- name: Test
run: uv run pytest tests/ -v --cov=ddogctl --cov-report=xml

release:
runs-on: ubuntu-latest
needs: test
concurrency: release
permissions:
id-token: write
contents: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_TOKEN }}

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Set up Python
run: uv python install 3.12

- name: Python Semantic Release
id: release
uses: python-semantic-release/python-semantic-release@v9.21.1
with:
github_token: ${{ secrets.RELEASE_TOKEN }}

- name: Publish to PyPI
if: steps.release.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish to GitHub Release
if: steps.release.outputs.released == 'true'
uses: python-semantic-release/publish-action@v9.21.1
with:
github_token: ${{ secrets.RELEASE_TOKEN }}
tag: ${{ steps.release.outputs.tag }}
15 changes: 11 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ Strict TDD (RED-GREEN-REFACTOR). Coverage target >90%. Reference implementation:

## Releasing

1. Bump version in `pyproject.toml` and `ddogctl/cli.py` (`@click.version_option`)
2. PR, merge, then tag: `git tag -a vX.Y.Z -m "vX.Y.Z"` and `git push origin vX.Y.Z`
3. CI publish job auto-triggers on `refs/tags/v*` via PyPI trusted publishing
- **First-time setup**: Configure PyPI Trusted Publishing at https://pypi.org/manage/project/ddogctl/settings/publishing/ (owner: `srgfrancisco`, repo: `ddogctl`, workflow: `publish.yml`)
Fully automated via `python-semantic-release`. On every merge to `main`:
1. CI tests run (Python 3.10-3.13)
2. Commits since last tag are analyzed for conventional commit prefixes
3. If `feat`/`fix`/`perf`/breaking changes found: version is bumped in `pyproject.toml`, tagged, published to PyPI, and a GitHub Release is created
4. If only `chore`/`docs`/`ci`/`refactor` commits: no release

Version lives in `pyproject.toml` only. `cli.py` reads it at runtime via `importlib.metadata`.

To force a major bump: use `feat!:` prefix or include `BREAKING CHANGE:` in commit body.

- **Setup requirements**: `RELEASE_TOKEN` (fine-grained PAT with Contents: Read & Write) in repo secrets, PyPI trusted publisher configured for workflow `release.yml`
2 changes: 1 addition & 1 deletion ddogctl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.0.0"

4 changes: 3 additions & 1 deletion ddogctl/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Main CLI entry point for Datadog CLI."""

from importlib.metadata import version as _get_version

import click
from rich.console import Console

Expand Down Expand Up @@ -36,7 +38,7 @@ def resolve_command(self, ctx, args):


@click.group(cls=AliasGroup)
@click.version_option(version="2.0.3")
@click.version_option(version=_get_version("ddogctl"))
@click.option(
"--profile",
default=None,
Expand Down
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,26 @@ line-length = 100

[tool.ruff]
line-length = 100

[tool.semantic_release]
version_toml = ["pyproject.toml:project.version"]
commit_parser = "conventional"
tag_format = "v{version}"
commit_message = "chore(release): v{version} [skip ci]"
build_command = "uv build"

[tool.semantic_release.branches.main]
match = "main"
prerelease = false

[tool.semantic_release.commit_parser_options]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]

[tool.semantic_release.changelog]
changelog_file = "CHANGELOG.md"
exclude_commit_patterns = ["chore\\(release\\):"]

[tool.semantic_release.remote]
type = "github"
token = { env = "GH_TOKEN" }
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading