|
1 | | -.PHONY: docs clean docs-serve install test test-coverage test-coverage-serve workflows run help requirements docker-build docker-test docker-push k8s-deploy k8s-delete run-daemon |
| 1 | +.PHONY: docs clean docs-serve install test test-coverage test-coverage-serve workflows run help requirements docker-build docker-test docker-push k8s-deploy k8s-delete run-daemon dist dist-clean airgap release |
2 | 2 |
|
3 | 3 | help: |
4 | 4 | @echo "Available Make Targets:" |
|
22 | 22 | @echo " install Install all dependencies" |
23 | 23 | @echo " requirements Generate requirements.txt files from pyproject.toml" |
24 | 24 | @echo "" |
| 25 | + @echo "Distribution Targets:" |
| 26 | + @echo " dist Build wheel and sdist" |
| 27 | + @echo " dist-clean Clean dist/ and build artifacts" |
| 28 | + @echo " airgap Build airgap bundles (RHEL 9 x86_64)" |
| 29 | + @echo " release Create GitHub release with all artifacts (via gh CLI)" |
| 30 | + @echo "" |
25 | 31 | @echo "Daemon Mode Targets:" |
26 | 32 | @echo " run-daemon Run daemon locally" |
27 | 33 | @echo " docker-build Build Docker image [TAG=version]" |
|
33 | 39 | @echo "Environment Variables:" |
34 | 40 | @echo " REGISTRY=registry.com Docker registry (required for push)" |
35 | 41 | @echo " TAG=version Docker image tag (default: latest)" |
| 42 | + @echo " AIRGAP_PYTHON=39,311 Python versions for airgap bundles (default: 39,311)" |
36 | 43 | @echo "" |
37 | 44 | @echo "Examples:" |
| 45 | + @echo " make dist Build wheel" |
| 46 | + @echo " make airgap Build airgap bundles for Python 3.9 + 3.11" |
| 47 | + @echo " make airgap AIRGAP_PYTHON=39 Build only Python 3.9 bundle" |
| 48 | + @echo " make release Push dist + airgap to GitHub release" |
38 | 49 | @echo " make docker-build TAG=v1.0.0" |
39 | 50 | @echo " export REGISTRY=docker.io/myuser && make docker-push" |
40 | 51 | @echo " REGISTRY=ghcr.io/org TAG=dev make docker-push" |
|
53 | 64 | sphinx-apidoc -o docs/source src/falcon_policy_scoring |
54 | 65 | cd docs && make html |
55 | 66 |
|
56 | | -clean: |
| 67 | +clean: dist-clean clean-test |
57 | 68 | @rm -rf data/*.json data/*.db data/*.sqlite && echo 'Cleaned database files in data/' |
58 | 69 | @rm -rf logs/*.log && echo 'Cleaned log files in logs/' |
59 | 70 | @rm -f results.json && echo 'Cleaned results.json' |
@@ -165,9 +176,77 @@ requirements: |
165 | 176 | # REGISTRY=ghcr.io/myorg TAG=dev make docker-push |
166 | 177 |
|
167 | 178 | TAG ?= latest |
| 179 | +AIRGAP_PYTHON ?= 39,311 |
168 | 180 |
|
169 | 181 | # Extract version from pyproject.toml |
170 | | -VERSION := $(shell python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])" 2>/dev/null || echo "0.0.0") |
| 182 | +VERSION := $(shell python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])" 2>/dev/null || python3 -c "import tomli as tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])" 2>/dev/null || echo "0.0.0") |
| 183 | + |
| 184 | +# --- Distribution targets --- |
| 185 | + |
| 186 | +dist: dist-clean |
| 187 | + @echo "Building wheel and sdist for v$(VERSION)..." |
| 188 | + python3 -m pip install --quiet build |
| 189 | + python3 -m build |
| 190 | + @echo "" |
| 191 | + @echo "Verifying wheel installs correctly..." |
| 192 | + @python3 -m pip install --quiet --force-reinstall dist/*.whl |
| 193 | + @policy-audit --version |
| 194 | + @echo "" |
| 195 | + @echo "Artifacts:" |
| 196 | + @ls -lh dist/ |
| 197 | + |
| 198 | +dist-clean: |
| 199 | + @rm -rf dist/ build/ src/*.egg-info |
| 200 | + @echo "Cleaned dist/, build/, *.egg-info" |
| 201 | + |
| 202 | +airgap: dist |
| 203 | + @echo "" |
| 204 | + @echo "Building airgap bundles for Python $(AIRGAP_PYTHON)..." |
| 205 | + @chmod +x scripts/build-airgap.sh |
| 206 | + scripts/build-airgap.sh --python $(AIRGAP_PYTHON) |
| 207 | + |
| 208 | +release: dist airgap |
| 209 | + @echo "" |
| 210 | + @echo "=== Creating GitHub Release v$(VERSION) ===" |
| 211 | + @if ! command -v gh &>/dev/null || ! gh auth status &>/dev/null; then \ |
| 212 | + echo ""; \ |
| 213 | + echo "gh CLI is not available or not authenticated."; \ |
| 214 | + echo "To publish this release manually:"; \ |
| 215 | + echo ""; \ |
| 216 | + echo "1. Tag the release:"; \ |
| 217 | + echo ""; \ |
| 218 | + echo " git tag v$(VERSION)"; \ |
| 219 | + echo " git push origin v$(VERSION)"; \ |
| 220 | + echo ""; \ |
| 221 | + echo "2. Go to: https://github.com/cs-shadowbq/falcon-policy-scoring/releases/new"; \ |
| 222 | + echo ""; \ |
| 223 | + echo "3. Select tag: v$(VERSION)"; \ |
| 224 | + echo " Title: falcon-policy-scoring v$(VERSION)"; \ |
| 225 | + echo " Description: Click 'Generate release notes' for changelog"; \ |
| 226 | + echo ""; \ |
| 227 | + echo "4. Attach these files from dist/:"; \ |
| 228 | + echo ""; \ |
| 229 | + ls dist/*.whl dist/*.tar.gz dist/SHA256SUMS 2>/dev/null | sort -u | sed 's/^/ /'; \ |
| 230 | + echo ""; \ |
| 231 | + echo "5. Verify checksums match dist/SHA256SUMS after upload."; \ |
| 232 | + echo ""; \ |
| 233 | + else \ |
| 234 | + echo ""; \ |
| 235 | + echo "Release artifacts:"; \ |
| 236 | + ls dist/*.whl dist/*.tar.gz dist/*-airgap-*.tar.gz dist/SHA256SUMS 2>/dev/null; \ |
| 237 | + echo ""; \ |
| 238 | + echo "Creating release..."; \ |
| 239 | + gh release create "v$(VERSION)" \ |
| 240 | + --title "falcon-policy-scoring v$(VERSION)" \ |
| 241 | + --generate-notes \ |
| 242 | + --notes-start-tag "$$(git tag --sort=-v:refname | sed -n '2p')" \ |
| 243 | + dist/*.whl \ |
| 244 | + dist/*.tar.gz \ |
| 245 | + dist/*-airgap-*.tar.gz \ |
| 246 | + dist/SHA256SUMS; \ |
| 247 | + echo ""; \ |
| 248 | + echo "Release published: https://github.com/cs-shadowbq/falcon-policy-scoring/releases/tag/v$(VERSION)"; \ |
| 249 | + fi |
171 | 250 |
|
172 | 251 | run-daemon: |
173 | 252 | python bin/policy-audit daemon --config config/config.yaml --output-dir ./output --verbose |
|
0 commit comments