Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 32 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Summary

<!-- Brief description of what this PR does and why -->

## Changes

-

## Type of change

- [ ] feat: new feature
- [ ] fix: bug fix
- [ ] docs: documentation update
- [ ] refactor: code restructuring
- [ ] test: test additions or updates
- [ ] chore: maintenance or dependency update

## Testing

- [ ] Tests added/updated
- [ ] All existing tests pass (`uv run pytest`)
- [ ] Linting passes (`uv run ruff check .`)

## Breaking changes

<!-- Describe any breaking changes, or write "None" -->

None

## Related issues

<!-- Link related issues: Fixes #123, Relates to #456 -->
117 changes: 117 additions & 0 deletions .github/workflows/github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Release

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
bump:
description: "Version bump type (leave empty to auto-detect from commits)"
required: false
type: choice
options:
- auto
- major
- minor
- patch
default: auto

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "push" ]; then
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
exit 0
fi

LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
BUMP="${{ inputs.bump }}"

if [ "$BUMP" = "auto" ] || [ -z "$BUMP" ]; then
if [ -z "$LATEST_STABLE" ]; then
COMMITS=$(git log --pretty=format:"%s%n%b" HEAD)
else
COMMITS=$(git log --pretty=format:"%s%n%b" "${LATEST_STABLE}..HEAD")
fi

BUMP="patch"
if echo "$COMMITS" | grep -qE '^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then
BUMP="major"
elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then
BUMP="minor"
fi
fi

if [ -z "$LATEST_STABLE" ]; then
MAJOR=0; MINOR=1; PATCH=0
else
VERSION="${LATEST_STABLE#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
fi

case "$BUMP" in
major)
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
;;
minor)
MINOR=$((MINOR + 1)); PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
TAG="v${NEXT_VERSION}"

echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"

- name: Create and push tag (manual dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"

- name: Generate changelog
id: changelog
run: |
PREVIOUS_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -2 | tail -1)
if [ -z "$PREVIOUS_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${PREVIOUS_TAG}..HEAD")
fi
{
echo "changelog<<EOF"
echo "$CHANGELOG"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: |
## What's Changed

${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
106 changes: 106 additions & 0 deletions .github/workflows/github_release_rc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Release Candidate

on:
push:
branches: [main]

permissions:
contents: write

jobs:
rc-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Determine version bump from commits
id: bump
run: |
LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)

if [ -z "$LATEST_STABLE" ]; then
COMMITS=$(git log --pretty=format:"%s%n%b" HEAD)
else
COMMITS=$(git log --pretty=format:"%s%n%b" "${LATEST_STABLE}..HEAD")
fi

BUMP="patch"

if echo "$COMMITS" | grep -qE '^feat(\(.+\))?!:|^fix(\(.+\))?!:|^refactor(\(.+\))?!:|^[a-z]+(\(.+\))?!:|BREAKING CHANGE:'; then
BUMP="major"
elif echo "$COMMITS" | grep -qE '^feat(\(.+\))?:'; then
BUMP="minor"
fi

echo "bump=${BUMP}" >> "$GITHUB_OUTPUT"

- name: Calculate next version
id: version
run: |
LATEST_STABLE=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1)
BUMP="${{ steps.bump.outputs.bump }}"

if [ -z "$LATEST_STABLE" ]; then
MAJOR=0; MINOR=1; PATCH=0
else
VERSION="${LATEST_STABLE#v}"
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
fi

case "$BUMP" in
major)
MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0
;;
minor)
MINOR=$((MINOR + 1)); PATCH=0
;;
patch)
PATCH=$((PATCH + 1))
;;
esac

NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
RC_COUNT=$(git tag --sort=-v:refname | grep -cE "^v${NEXT_VERSION}-rc\." || true)
RC_NUM=$((RC_COUNT + 1))
RC_TAG="v${NEXT_VERSION}-rc.${RC_NUM}"

echo "tag=${RC_TAG}" >> "$GITHUB_OUTPUT"
echo "version=${NEXT_VERSION}-rc.${RC_NUM}" >> "$GITHUB_OUTPUT"
echo "bump=${BUMP}" >> "$GITHUB_OUTPUT"

- name: Generate changelog
id: changelog
run: |
LATEST_TAG=$(git tag --sort=-v:refname | head -1)
if [ -z "$LATEST_TAG" ]; then
CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD)
else
CHANGELOG=$(git log --pretty=format:"- %s (%h)" "${LATEST_TAG}..HEAD")
fi
{
echo "changelog<<EOF"
echo "$CHANGELOG"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Create RC tag
run: |
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"

- name: Create GitHub pre-release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: ${{ steps.version.outputs.tag }}
body: |
## Pre-release: ${{ steps.version.outputs.tag }}

**Version bump**: `${{ steps.version.outputs.bump }}` (determined from conventional commits)

${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: true
54 changes: 54 additions & 0 deletions .github/workflows/lint_and_scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lint & Security Scan

on:
pull_request:
branches: [main]

permissions:
contents: read
security-events: write

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

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

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

- name: Ruff lint
run: uv run ruff check .

- name: Ruff format check
run: uv run ruff format --check .

security:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Gitleaks secret scan
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install uv
uses: astral-sh/setup-uv@v5

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

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

- name: Pip audit
run: uv run pip-audit
30 changes: 30 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Pull Request

on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.12", "3.13"]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

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

- name: Run tests
run: uv run pytest --tb=short -q
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ venv/
.pytest_cache/
.coverage
htmlcov/
*.so
.mypy_cache/
.ruff_cache/
.env
.env.*
!.env.example
*.lock
Pulumi.*.yaml
!Pulumi.yaml
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: detect-private-key

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.10
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.1
hooks:
- id: gitleaks
Loading
Loading