Skip to content

Commit 452593c

Browse files
author
Ryan Mullins
committed
Initial import
0 parents  commit 452593c

22 files changed

+2459
-0
lines changed

.github/WORKFLOWS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# GitHub Workflows
2+
3+
This directory contains the GitHub Actions workflows for the fastapi-secure-errors project.
4+
5+
## Workflows
6+
7+
### 1. Tests (`tests.yml`)
8+
- **Trigger**: Push to main/develop branches, Pull requests
9+
- **Purpose**: Run tests and generate coverage reports
10+
- **Actions**:
11+
- Install dependencies with uv
12+
- Run pytest with coverage
13+
- Upload coverage to Codecov
14+
15+
### 2. Release (`release.yml`)
16+
- **Trigger**: When a GitHub release is published
17+
- **Purpose**: Build and package the project for distribution
18+
- **Actions**:
19+
- Run tests to ensure quality
20+
- Build the package using `uv build`
21+
- Upload package artifacts (wheel and source distribution)
22+
23+
### 3. Create Release (`create-release.yml`)
24+
- **Trigger**: Manual workflow dispatch
25+
- **Purpose**: Create a new release with version bumping
26+
- **Inputs**:
27+
- `version`: The version number for the release (e.g., "1.0.0")
28+
- `release_type`: Either "release" or "prerelease"
29+
- **Actions**:
30+
- Update version in pyproject.toml
31+
- Run tests
32+
- Build package
33+
- Commit version bump
34+
- Create GitHub release
35+
36+
## Usage
37+
38+
### Creating a Release
39+
40+
1. **Using the Create Release Workflow** (Recommended):
41+
- Go to the Actions tab in GitHub
42+
- Select "Create Release" workflow
43+
- Click "Run workflow"
44+
- Enter the version number and release type
45+
- Click "Run workflow"
46+
47+
2. **Manual Release**:
48+
- Create a new tag: `git tag v1.0.0`
49+
- Push the tag: `git push origin v1.0.0`
50+
- Create a release in GitHub UI using that tag
51+
52+
### Artifacts
53+
54+
The release workflow generates the following artifacts:
55+
- **Source distribution** (`.tar.gz`): Contains the source code
56+
- **Wheel distribution** (`.whl`): Ready-to-install binary package
57+
58+
These artifacts are automatically attached to the GitHub release and can be downloaded or used for PyPI publishing.
59+
60+
## Future Enhancements
61+
62+
- [ ] Add PyPI publishing to the release workflow
63+
- [ ] Add security scanning with CodeQL
64+
- [ ] Add dependency updates with Dependabot
65+
- [ ] Add changelog generation
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., 1.0.0)'
8+
required: true
9+
type: string
10+
release_type:
11+
description: 'Type of release'
12+
required: true
13+
default: 'release'
14+
type: choice
15+
options:
16+
- release
17+
- prerelease
18+
19+
jobs:
20+
create-release:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.13'
33+
34+
- name: Install uv
35+
uses: astral-sh/setup-uv@v4
36+
with:
37+
version: "latest"
38+
39+
- name: Install dependencies
40+
run: |
41+
uv sync --all-extras
42+
43+
- name: Update version in pyproject.toml
44+
run: |
45+
uv version ${{ github.event.inputs.version }}
46+
47+
- name: Build package
48+
run: |
49+
uv build
50+
51+
- name: Commit version bump
52+
run: |
53+
git config --local user.email "action@github.com"
54+
git config --local user.name "GitHub Action"
55+
git add pyproject.toml
56+
git commit -m "Bump version to ${{ github.event.inputs.version }}"
57+
git push
58+
59+
- name: Create Release
60+
uses: softprops/action-gh-release@v2
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
with:
64+
tag_name: v${{ github.event.inputs.version }}
65+
name: Release v${{ github.event.inputs.version }}
66+
draft: false
67+
prerelease: ${{ github.event.inputs.release_type == 'prerelease' }}
68+
body: |
69+
## Changes in v${{ github.event.inputs.version }}
70+
71+
<!-- Add release notes here -->
72+
73+
## Installation
74+
75+
```bash
76+
pip install fastapi-secure-errors==${{ github.event.inputs.version }}
77+
```
78+
79+
## Assets
80+
81+
The package distributions are available as build artifacts in the release workflow.

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
environment: release # Specify the release environment
11+
permissions:
12+
id-token: write # Required for trusted publishing
13+
contents: write # Required to add release assets and checkout code
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.13'
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v4
26+
with:
27+
version: "latest"
28+
29+
- name: Install dependencies
30+
run: |
31+
uv sync --all-extras
32+
33+
- name: Build package
34+
run: |
35+
uv build
36+
37+
- name: Upload package artifacts
38+
uses: actions/upload-artifact@v4
39+
with:
40+
name: python-package-distributions
41+
path: dist/
42+
43+
- name: Verify package contents
44+
run: |
45+
ls -la dist/
46+
echo "Package files created:"
47+
for file in dist/*; do
48+
echo " - $(basename "$file")"
49+
done
50+
51+
- name: Add package to release assets
52+
uses: softprops/action-gh-release@v2
53+
with:
54+
files: dist/*
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
# Publish to PyPI using trusted publishing
59+
- name: Publish to PyPI
60+
uses: pypa/gh-action-pypi-publish@release/v1
61+
with:
62+
# No token needed with trusted publishing!
63+
verbose: true

.github/workflows/tests.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.13']
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v4
27+
with:
28+
version: "latest"
29+
30+
- name: Install dependencies
31+
run: |
32+
uv sync --all-extras --group test
33+
34+
- name: Run tests with coverage
35+
run: |
36+
uv run pytest tests/ --cov=src --cov-report=xml --cov-report=term-missing -v
37+
38+
# - name: Upload coverage to Codecov
39+
# uses: codecov/codecov-action@v4
40+
# with:
41+
# file: ./coverage.xml
42+
# fail_ci_if_error: false

0 commit comments

Comments
 (0)