Skip to content

Commit 681d368

Browse files
iamspathanclaude
andcommitted
Add CI/CD workflows, version pinning, and release tooling
- Add CI workflow (ruff + pytest on Python 3.11/3.12 matrix) - Add release workflow (PyPI via OIDC, npm, GitHub Release on tag push) - Pin PyPI version in npm wrapper to match package.json version - Add bump-version.sh script to keep versions in sync - Document release process in CONTRIBUTING.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ad720a1 commit 681d368

File tree

5 files changed

+178
-1
lines changed

5 files changed

+178
-1
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.11", "3.12"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: pip install -e ".[dev]"
26+
27+
- name: Lint with ruff
28+
run: ruff check src/ tests/
29+
30+
- name: Run tests
31+
run: pytest

.github/workflows/release.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.11", "3.12"]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
23+
- name: Install dependencies
24+
run: pip install -e ".[dev]"
25+
26+
- name: Lint with ruff
27+
run: ruff check src/ tests/
28+
29+
- name: Run tests
30+
run: pytest
31+
32+
publish-pypi:
33+
needs: test
34+
runs-on: ubuntu-latest
35+
permissions:
36+
id-token: write
37+
environment: pypi
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
46+
47+
- name: Install build tools
48+
run: pip install build
49+
50+
- name: Build sdist and wheel
51+
run: python -m build
52+
53+
- name: Publish to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
56+
publish-npm:
57+
needs: publish-pypi
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- uses: actions/checkout@v4
62+
63+
- name: Set up Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: "20"
67+
registry-url: "https://registry.npmjs.org"
68+
69+
- name: Publish to npm
70+
working-directory: npm
71+
run: npm publish
72+
env:
73+
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
74+
75+
github-release:
76+
needs: publish-npm
77+
runs-on: ubuntu-latest
78+
permissions:
79+
contents: write
80+
81+
steps:
82+
- uses: actions/checkout@v4
83+
84+
- name: Create GitHub Release
85+
run: gh release create "${{ github.ref_name }}" --generate-notes
86+
env:
87+
GH_TOKEN: ${{ github.token }}

CONTRIBUTING.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,26 @@ Before opening a PR, verify:
194194
- [ ] New rules have valid YAML schema and OWASP mapping
195195
- [ ] Commit messages are clear and descriptive
196196

197+
## Releasing
198+
199+
Releases are automated via GitHub Actions. When a version tag is pushed, CI publishes to PyPI and npm automatically.
200+
201+
```bash
202+
# Bump version in pyproject.toml + npm/package.json, commit, and tag
203+
./scripts/bump-version.sh 1.1.0
204+
205+
# Push to trigger the release workflow
206+
git push origin main --tags
207+
```
208+
209+
The release workflow will:
210+
1. Run the full test suite
211+
2. Publish to PyPI (via OIDC trusted publishing)
212+
3. Publish to npm (via `NODE_AUTH_TOKEN` secret)
213+
4. Create a GitHub Release with auto-generated notes
214+
215+
**Important**: PyPI is published before npm because the npm wrapper installs from PyPI at runtime.
216+
197217
## Reporting Issues
198218

199219
### Bug reports

npm/lib/venv-manager.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const fs = require("fs");
55
const { execFileSync } = require("child_process");
66
const { findPython, MIN_MAJOR, MIN_MINOR } = require("./python-resolver");
77

8+
const PKG = require("../package.json");
9+
810
const VENV_DIR = path.join(__dirname, "..", ".venv");
911
const PIP_PACKAGE = "llm-authz-audit";
1012
const REPO_ROOT = path.join(__dirname, "..", "..");
@@ -65,7 +67,7 @@ function setup() {
6567
stdio: "inherit",
6668
});
6769
} else {
68-
execFileSync(pip, ["-m", "pip", "install", PIP_PACKAGE], {
70+
execFileSync(pip, ["-m", "pip", "install", `${PIP_PACKAGE}==${PKG.version}`], {
6971
stdio: "inherit",
7072
});
7173
}

scripts/bump-version.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ $# -ne 1 ]; then
5+
echo "Usage: $0 <version>"
6+
echo "Example: $0 1.1.0"
7+
exit 1
8+
fi
9+
10+
VERSION="$1"
11+
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
12+
13+
# Validate semver format
14+
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
15+
echo "Error: version must be in semver format (e.g. 1.2.3)"
16+
exit 1
17+
fi
18+
19+
echo "Bumping version to $VERSION..."
20+
21+
# Update pyproject.toml
22+
sed -i.bak "s/^version = \".*\"/version = \"$VERSION\"/" "$REPO_ROOT/pyproject.toml"
23+
rm -f "$REPO_ROOT/pyproject.toml.bak"
24+
25+
# Update npm/package.json
26+
cd "$REPO_ROOT/npm"
27+
npm version "$VERSION" --no-git-tag-version --allow-same-version
28+
29+
# Commit and tag
30+
cd "$REPO_ROOT"
31+
git add pyproject.toml npm/package.json
32+
git commit -m "chore: bump version to $VERSION"
33+
git tag "v$VERSION"
34+
35+
echo ""
36+
echo "Done! Version bumped to $VERSION and tagged v$VERSION."
37+
echo "Run 'git push origin main --tags' to trigger the release workflow."

0 commit comments

Comments
 (0)