strapi-kit 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- strapi_kit-0.0.1/.coderabbit.yaml +83 -0
- strapi_kit-0.0.1/.env.example +37 -0
- strapi_kit-0.0.1/.github/dependabot.yml +15 -0
- strapi_kit-0.0.1/.github/pull_request_template.md +63 -0
- strapi_kit-0.0.1/.github/workflows/ci.yml +106 -0
- strapi_kit-0.0.1/.github/workflows/dev-release.yml +147 -0
- strapi_kit-0.0.1/.github/workflows/document.yml +140 -0
- strapi_kit-0.0.1/.github/workflows/guard-main-origin.yml +26 -0
- strapi_kit-0.0.1/.github/workflows/publish-testpypi.yml +208 -0
- strapi_kit-0.0.1/.github/workflows/release.yml +171 -0
- strapi_kit-0.0.1/.gitignore +174 -0
- strapi_kit-0.0.1/.pre-commit-config.yaml +77 -0
- strapi_kit-0.0.1/.secrets.baseline +152 -0
- strapi_kit-0.0.1/CLAUDE.md +858 -0
- strapi_kit-0.0.1/LICENSE +21 -0
- strapi_kit-0.0.1/Makefile +260 -0
- strapi_kit-0.0.1/PKG-INFO +1098 -0
- strapi_kit-0.0.1/README.md +1053 -0
- strapi_kit-0.0.1/codecov.yml +60 -0
- strapi_kit-0.0.1/docs/changelog.md +55 -0
- strapi_kit-0.0.1/docs/configuration.md +119 -0
- strapi_kit-0.0.1/docs/development/architecture.md +327 -0
- strapi_kit-0.0.1/docs/development/contributing.md +298 -0
- strapi_kit-0.0.1/docs/development/release-process.md +403 -0
- strapi_kit-0.0.1/docs/development/testing.md +405 -0
- strapi_kit-0.0.1/docs/export-import.md +347 -0
- strapi_kit-0.0.1/docs/index.md +89 -0
- strapi_kit-0.0.1/docs/installation.md +72 -0
- strapi_kit-0.0.1/docs/media.md +625 -0
- strapi_kit-0.0.1/docs/models.md +639 -0
- strapi_kit-0.0.1/docs/quickstart.md +71 -0
- strapi_kit-0.0.1/docs/stylesheets/extra.css +16 -0
- strapi_kit-0.0.1/examples/MIGRATION_GUIDE.md +424 -0
- strapi_kit-0.0.1/examples/async_operations.py +79 -0
- strapi_kit-0.0.1/examples/basic_crud.py +82 -0
- strapi_kit-0.0.1/examples/config_di_demo.py +204 -0
- strapi_kit-0.0.1/examples/export_import_with_media.py +234 -0
- strapi_kit-0.0.1/examples/export_import_with_schemas.py +102 -0
- strapi_kit-0.0.1/examples/full_migration_v5.py +370 -0
- strapi_kit-0.0.1/examples/simple_migration.py +90 -0
- strapi_kit-0.0.1/examples/verify_installation.py +108 -0
- strapi_kit-0.0.1/mkdocs.yml +114 -0
- strapi_kit-0.0.1/pyproject.toml +156 -0
- strapi_kit-0.0.1/src/strapi_kit/__init__.py +97 -0
- strapi_kit-0.0.1/src/strapi_kit/__version__.py +15 -0
- strapi_kit-0.0.1/src/strapi_kit/_version.py +34 -0
- strapi_kit-0.0.1/src/strapi_kit/auth/__init__.py +7 -0
- strapi_kit-0.0.1/src/strapi_kit/auth/api_token.py +48 -0
- strapi_kit-0.0.1/src/strapi_kit/cache/__init__.py +5 -0
- strapi_kit-0.0.1/src/strapi_kit/cache/schema_cache.py +211 -0
- strapi_kit-0.0.1/src/strapi_kit/client/__init__.py +11 -0
- strapi_kit-0.0.1/src/strapi_kit/client/async_client.py +1032 -0
- strapi_kit-0.0.1/src/strapi_kit/client/base.py +460 -0
- strapi_kit-0.0.1/src/strapi_kit/client/sync_client.py +980 -0
- strapi_kit-0.0.1/src/strapi_kit/config_provider.py +368 -0
- strapi_kit-0.0.1/src/strapi_kit/exceptions/__init__.py +37 -0
- strapi_kit-0.0.1/src/strapi_kit/exceptions/errors.py +205 -0
- strapi_kit-0.0.1/src/strapi_kit/export/__init__.py +10 -0
- strapi_kit-0.0.1/src/strapi_kit/export/exporter.py +384 -0
- strapi_kit-0.0.1/src/strapi_kit/export/importer.py +619 -0
- strapi_kit-0.0.1/src/strapi_kit/export/media_handler.py +322 -0
- strapi_kit-0.0.1/src/strapi_kit/export/relation_resolver.py +172 -0
- strapi_kit-0.0.1/src/strapi_kit/models/__init__.py +104 -0
- strapi_kit-0.0.1/src/strapi_kit/models/bulk.py +69 -0
- strapi_kit-0.0.1/src/strapi_kit/models/config.py +174 -0
- strapi_kit-0.0.1/src/strapi_kit/models/enums.py +97 -0
- strapi_kit-0.0.1/src/strapi_kit/models/export_format.py +166 -0
- strapi_kit-0.0.1/src/strapi_kit/models/import_options.py +142 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/__init__.py +1 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/fields.py +65 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/filters.py +611 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/pagination.py +168 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/populate.py +281 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/query.py +429 -0
- strapi_kit-0.0.1/src/strapi_kit/models/request/sort.py +147 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/__init__.py +1 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/base.py +75 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/component.py +67 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/media.py +91 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/meta.py +44 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/normalized.py +168 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/relation.py +48 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/v4.py +70 -0
- strapi_kit-0.0.1/src/strapi_kit/models/response/v5.py +57 -0
- strapi_kit-0.0.1/src/strapi_kit/models/schema.py +93 -0
- strapi_kit-0.0.1/src/strapi_kit/operations/__init__.py +16 -0
- strapi_kit-0.0.1/src/strapi_kit/operations/media.py +226 -0
- strapi_kit-0.0.1/src/strapi_kit/operations/streaming.py +144 -0
- strapi_kit-0.0.1/src/strapi_kit/parsers/__init__.py +5 -0
- strapi_kit-0.0.1/src/strapi_kit/parsers/version_detecting.py +171 -0
- strapi_kit-0.0.1/src/strapi_kit/protocols.py +455 -0
- strapi_kit-0.0.1/src/strapi_kit/utils/__init__.py +15 -0
- strapi_kit-0.0.1/src/strapi_kit/utils/rate_limiter.py +201 -0
- strapi_kit-0.0.1/src/strapi_kit/utils/uid.py +88 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# CodeRabbit Configuration for strapi-kit
|
|
2
|
+
# AI-powered code review for pull requests
|
|
3
|
+
# Configuration follows CodeRabbit v2 schema
|
|
4
|
+
|
|
5
|
+
# Language configuration
|
|
6
|
+
language: en-US
|
|
7
|
+
|
|
8
|
+
# Early access features
|
|
9
|
+
early_access: false
|
|
10
|
+
|
|
11
|
+
# Tone and style
|
|
12
|
+
tone_instructions: |
|
|
13
|
+
- Be constructive and helpful
|
|
14
|
+
- Focus on code quality, security, and maintainability
|
|
15
|
+
- Suggest improvements with examples when possible
|
|
16
|
+
- Acknowledge good practices
|
|
17
|
+
- Be concise but clear
|
|
18
|
+
|
|
19
|
+
# Review settings
|
|
20
|
+
reviews:
|
|
21
|
+
high_level_summary: true
|
|
22
|
+
review_status: true
|
|
23
|
+
collapse_walkthrough: false
|
|
24
|
+
|
|
25
|
+
auto_review:
|
|
26
|
+
enabled: true
|
|
27
|
+
drafts: false
|
|
28
|
+
base_branches:
|
|
29
|
+
- main
|
|
30
|
+
- dev
|
|
31
|
+
|
|
32
|
+
# Path-based filters (files to skip reviewing)
|
|
33
|
+
path_filters:
|
|
34
|
+
- "!**/*.md"
|
|
35
|
+
- "!**/*.txt"
|
|
36
|
+
- "!**/*.json"
|
|
37
|
+
- "!**/*.yaml"
|
|
38
|
+
- "!**/*.yml"
|
|
39
|
+
- "!**/__pycache__/**"
|
|
40
|
+
- "!**/*.pyc"
|
|
41
|
+
- "!**/dist/**"
|
|
42
|
+
- "!**/build/**"
|
|
43
|
+
- "!**/.venv/**"
|
|
44
|
+
|
|
45
|
+
# Path-specific instructions
|
|
46
|
+
path_instructions:
|
|
47
|
+
- path: "tests/**"
|
|
48
|
+
instructions: |
|
|
49
|
+
- Focus on test correctness and coverage
|
|
50
|
+
- Ensure both sync and async tests are present
|
|
51
|
+
- Check for proper use of fixtures and mocks
|
|
52
|
+
- Verify async tests use proper asyncio patterns
|
|
53
|
+
|
|
54
|
+
- path: "src/strapi_kit/**"
|
|
55
|
+
instructions: |
|
|
56
|
+
- Verify type hints are complete and accurate (mypy strict mode)
|
|
57
|
+
- Check for proper exception handling with specific exception types
|
|
58
|
+
- Ensure docstrings follow Google style
|
|
59
|
+
- Look for security issues (injection, secrets, etc.)
|
|
60
|
+
- Verify both sync and async implementations are consistent
|
|
61
|
+
- Check Pydantic models have proper validation
|
|
62
|
+
|
|
63
|
+
- path: "**/*.py"
|
|
64
|
+
instructions: |
|
|
65
|
+
- Python 3.12+ features are encouraged
|
|
66
|
+
- Use type hints for all functions
|
|
67
|
+
- Follow project's exception hierarchy
|
|
68
|
+
- Keep functions focused and single-purpose
|
|
69
|
+
- Avoid over-engineering or premature abstraction
|
|
70
|
+
|
|
71
|
+
# AI chat
|
|
72
|
+
chat:
|
|
73
|
+
auto_reply: true
|
|
74
|
+
|
|
75
|
+
# Knowledge base
|
|
76
|
+
knowledge_base:
|
|
77
|
+
learnings:
|
|
78
|
+
scope: local
|
|
79
|
+
code_guidelines:
|
|
80
|
+
enabled: true
|
|
81
|
+
filePatterns:
|
|
82
|
+
- "CLAUDE.md"
|
|
83
|
+
- "AGENTS.md"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Strapi Configuration Example
|
|
2
|
+
# Copy this file to .env and fill in your values
|
|
3
|
+
|
|
4
|
+
# Required: Strapi instance URL
|
|
5
|
+
STRAPI_BASE_URL=http://localhost:1337
|
|
6
|
+
|
|
7
|
+
# Required: API authentication token
|
|
8
|
+
# Get this from Strapi Admin Panel → Settings → API Tokens
|
|
9
|
+
STRAPI_API_TOKEN=your-api-token-here
|
|
10
|
+
|
|
11
|
+
# Optional: API version (v4, v5, or auto-detect)
|
|
12
|
+
# STRAPI_API_VERSION=auto
|
|
13
|
+
|
|
14
|
+
# Optional: Request timeout in seconds (default: 30.0)
|
|
15
|
+
# STRAPI_TIMEOUT=30.0
|
|
16
|
+
|
|
17
|
+
# Optional: Maximum concurrent connections (default: 10)
|
|
18
|
+
# STRAPI_MAX_CONNECTIONS=10
|
|
19
|
+
|
|
20
|
+
# Optional: Verify SSL certificates (default: true)
|
|
21
|
+
# STRAPI_VERIFY_SSL=true
|
|
22
|
+
|
|
23
|
+
# Optional: Rate limit per second (default: None/unlimited)
|
|
24
|
+
# STRAPI_RATE_LIMIT_PER_SECOND=10.0
|
|
25
|
+
|
|
26
|
+
# Retry Configuration
|
|
27
|
+
# Optional: Maximum retry attempts (default: 3, range: 1-10)
|
|
28
|
+
# STRAPI_RETRY_MAX_ATTEMPTS=3
|
|
29
|
+
|
|
30
|
+
# Optional: Initial wait time before first retry in seconds (default: 1.0)
|
|
31
|
+
# STRAPI_RETRY_INITIAL_WAIT=1.0
|
|
32
|
+
|
|
33
|
+
# Optional: Maximum wait time between retries in seconds (default: 60.0)
|
|
34
|
+
# STRAPI_RETRY_MAX_WAIT=60.0
|
|
35
|
+
|
|
36
|
+
# Optional: Exponential backoff multiplier (default: 2.0)
|
|
37
|
+
# STRAPI_RETRY_EXPONENTIAL_BASE=2.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "pip"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
target-branch: "dev"
|
|
8
|
+
allow:
|
|
9
|
+
- dependency-type: "all"
|
|
10
|
+
|
|
11
|
+
- package-ecosystem: "github-actions"
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: "weekly"
|
|
15
|
+
target-branch: "dev"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
<!-- Provide a brief description of the changes in this PR -->
|
|
4
|
+
|
|
5
|
+
## Type of Change
|
|
6
|
+
|
|
7
|
+
<!-- Mark the relevant option with an "x" -->
|
|
8
|
+
|
|
9
|
+
- [ ] 🐛 Bug fix (non-breaking change that fixes an issue)
|
|
10
|
+
- [ ] ✨ New feature (non-breaking change that adds functionality)
|
|
11
|
+
- [ ] 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
|
12
|
+
- [ ] 📝 Documentation update
|
|
13
|
+
- [ ] 🔧 Configuration change
|
|
14
|
+
- [ ] ♻️ Code refactoring
|
|
15
|
+
- [ ] ✅ Test update
|
|
16
|
+
- [ ] 🎨 Style/formatting change
|
|
17
|
+
|
|
18
|
+
## Changes Made
|
|
19
|
+
|
|
20
|
+
<!-- List the main changes made in this PR -->
|
|
21
|
+
|
|
22
|
+
-
|
|
23
|
+
-
|
|
24
|
+
-
|
|
25
|
+
|
|
26
|
+
## Testing
|
|
27
|
+
|
|
28
|
+
<!-- Describe how you tested these changes -->
|
|
29
|
+
|
|
30
|
+
- [ ] Added new tests
|
|
31
|
+
- [ ] Updated existing tests
|
|
32
|
+
- [ ] All tests pass locally
|
|
33
|
+
- [ ] Tested both sync and async variants (if applicable)
|
|
34
|
+
|
|
35
|
+
## Checklist
|
|
36
|
+
|
|
37
|
+
<!-- Mark completed items with an "x" -->
|
|
38
|
+
|
|
39
|
+
- [ ] My code follows the project's style guidelines
|
|
40
|
+
- [ ] I have performed a self-review of my code
|
|
41
|
+
- [ ] I have commented my code, particularly in hard-to-understand areas
|
|
42
|
+
- [ ] I have made corresponding changes to the documentation
|
|
43
|
+
- [ ] My changes generate no new warnings
|
|
44
|
+
- [ ] I have added tests that prove my fix is effective or that my feature works
|
|
45
|
+
- [ ] New and existing unit tests pass locally with my changes
|
|
46
|
+
- [ ] I have run `make pre-commit` successfully
|
|
47
|
+
- [ ] Type checking passes (`mypy src/strapi_kit/`)
|
|
48
|
+
- [ ] Linting passes (`ruff check src/ tests/`)
|
|
49
|
+
|
|
50
|
+
## Related Issues
|
|
51
|
+
|
|
52
|
+
<!-- Link related issues here -->
|
|
53
|
+
|
|
54
|
+
Closes #
|
|
55
|
+
Related to #
|
|
56
|
+
|
|
57
|
+
## Additional Notes
|
|
58
|
+
|
|
59
|
+
<!-- Any additional information or context -->
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
**Note:** This PR will be automatically reviewed by CodeRabbit AI. Please address any concerns raised before requesting human review.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
name: Test-Matrix
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
tests:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
python:
|
|
20
|
+
- "3.12"
|
|
21
|
+
- "3.13"
|
|
22
|
+
- "3.14"
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: 🛎️ Checkout
|
|
26
|
+
uses: actions/checkout@v6
|
|
27
|
+
with:
|
|
28
|
+
fetch-depth: 0
|
|
29
|
+
|
|
30
|
+
- name: 🐍 Set up Python
|
|
31
|
+
uses: actions/setup-python@v6
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python }}
|
|
34
|
+
|
|
35
|
+
- name: ⚡ Install uv (with cache)
|
|
36
|
+
uses: astral-sh/setup-uv@v7
|
|
37
|
+
with:
|
|
38
|
+
enable-cache: true
|
|
39
|
+
|
|
40
|
+
- name: ▶️ Run Tests
|
|
41
|
+
env:
|
|
42
|
+
CI: "true"
|
|
43
|
+
run: |
|
|
44
|
+
# Install project with dev dependencies
|
|
45
|
+
uv pip install --system -e ".[dev]"
|
|
46
|
+
|
|
47
|
+
# Run tests
|
|
48
|
+
echo "Running tests for Python ${{ matrix.python }}"
|
|
49
|
+
pytest -v
|
|
50
|
+
|
|
51
|
+
- name: 🔍 Quality Gates
|
|
52
|
+
if: matrix.python == '3.13'
|
|
53
|
+
run: |
|
|
54
|
+
# Run linting
|
|
55
|
+
ruff check src/ tests/
|
|
56
|
+
|
|
57
|
+
# Run type checking
|
|
58
|
+
mypy src/strapi_kit/
|
|
59
|
+
|
|
60
|
+
# Run security checks
|
|
61
|
+
bandit -c pyproject.toml -r src/
|
|
62
|
+
|
|
63
|
+
# Coverage job - run all tests in one job for simplicity
|
|
64
|
+
coverage:
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
steps:
|
|
67
|
+
- name: 🛎️ Checkout
|
|
68
|
+
uses: actions/checkout@v6
|
|
69
|
+
|
|
70
|
+
- name: 🐍 Set up Python
|
|
71
|
+
uses: actions/setup-python@v6
|
|
72
|
+
with:
|
|
73
|
+
python-version: "3.13"
|
|
74
|
+
|
|
75
|
+
- name: ⚡ Install uv
|
|
76
|
+
uses: astral-sh/setup-uv@v7
|
|
77
|
+
|
|
78
|
+
- name: 📊 Run all tests with coverage
|
|
79
|
+
run: |
|
|
80
|
+
# Install project with dev dependencies
|
|
81
|
+
uv pip install --system -e ".[dev]"
|
|
82
|
+
|
|
83
|
+
# Run tests with coverage
|
|
84
|
+
pytest --cov=strapi_kit --cov-report=xml --cov-report=term -v
|
|
85
|
+
|
|
86
|
+
- name: 📈 Coverage upload
|
|
87
|
+
uses: codecov/codecov-action@v5
|
|
88
|
+
with:
|
|
89
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
90
|
+
files: coverage.xml
|
|
91
|
+
flags: unittests
|
|
92
|
+
fail_ci_if_error: false
|
|
93
|
+
|
|
94
|
+
test-matrix-expected:
|
|
95
|
+
name: Test-MatrixExpected
|
|
96
|
+
runs-on: ubuntu-latest
|
|
97
|
+
needs: [tests, coverage]
|
|
98
|
+
if: ${{ always() }}
|
|
99
|
+
steps:
|
|
100
|
+
- name: ✅ Verify matrix results
|
|
101
|
+
run: |
|
|
102
|
+
if [[ "${{ needs.tests.result }}" != "success" || "${{ needs.coverage.result }}" != "success" ]]; then
|
|
103
|
+
echo "Upstream checks failed"
|
|
104
|
+
exit 1
|
|
105
|
+
fi
|
|
106
|
+
echo "All required checks passed"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
name: Dev Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- dev
|
|
7
|
+
workflow_dispatch: # Allow manual triggering
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
id-token: write # OIDC → Trusted Publishing
|
|
11
|
+
contents: read # Read repository contents
|
|
12
|
+
pull-requests: read # Read PR labels for version calculation
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
dev-release:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
environment: testpypi
|
|
18
|
+
env:
|
|
19
|
+
PYTHON_VERSION: "3.12"
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: 🛎️ Checkout repository
|
|
23
|
+
uses: actions/checkout@v6
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0 # Needed for version calculation
|
|
26
|
+
fetch-tags: true
|
|
27
|
+
|
|
28
|
+
- name: 🐍 Set up Python
|
|
29
|
+
uses: actions/setup-python@v6
|
|
30
|
+
with:
|
|
31
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
32
|
+
|
|
33
|
+
- name: ⚡ Install uv (with cache)
|
|
34
|
+
uses: astral-sh/setup-uv@v7
|
|
35
|
+
with:
|
|
36
|
+
enable-cache: true
|
|
37
|
+
|
|
38
|
+
- name: 📦 Install build tools
|
|
39
|
+
run: |
|
|
40
|
+
uv pip install --system build hatch
|
|
41
|
+
|
|
42
|
+
- name: 🔍 Check for PR with release labels
|
|
43
|
+
id: pr_labels
|
|
44
|
+
env:
|
|
45
|
+
GH_TOKEN: ${{ github.token }}
|
|
46
|
+
run: |
|
|
47
|
+
# Find open PR from dev to main
|
|
48
|
+
PR_JSON=$(gh pr list --head dev --base main --state open --json number,labels --limit 1)
|
|
49
|
+
|
|
50
|
+
if [ "$PR_JSON" = "[]" ]; then
|
|
51
|
+
echo "No open PR from dev to main found"
|
|
52
|
+
echo "RELEASE_TYPE=minor" >> $GITHUB_OUTPUT
|
|
53
|
+
else
|
|
54
|
+
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.[0].number')
|
|
55
|
+
LABELS=$(echo "$PR_JSON" | jq -r '.[0].labels[].name' 2>/dev/null || echo "")
|
|
56
|
+
|
|
57
|
+
echo "Found PR #$PR_NUMBER with labels: $LABELS"
|
|
58
|
+
|
|
59
|
+
if echo "$LABELS" | grep -q "release:major"; then
|
|
60
|
+
echo "RELEASE_TYPE=major" >> $GITHUB_OUTPUT
|
|
61
|
+
echo "🏷️ Release type: MAJOR"
|
|
62
|
+
elif echo "$LABELS" | grep -q "release:minor"; then
|
|
63
|
+
echo "RELEASE_TYPE=minor" >> $GITHUB_OUTPUT
|
|
64
|
+
echo "🏷️ Release type: MINOR"
|
|
65
|
+
elif echo "$LABELS" | grep -q "release:patch"; then
|
|
66
|
+
echo "RELEASE_TYPE=patch" >> $GITHUB_OUTPUT
|
|
67
|
+
echo "🏷️ Release type: PATCH"
|
|
68
|
+
else
|
|
69
|
+
echo "RELEASE_TYPE=minor" >> $GITHUB_OUTPUT
|
|
70
|
+
echo "🏷️ Release type: minor (default)"
|
|
71
|
+
fi
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
- name: 🏷️ Calculate dev version
|
|
75
|
+
id: version
|
|
76
|
+
run: |
|
|
77
|
+
# Get the latest tag
|
|
78
|
+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
|
79
|
+
CURRENT_VERSION=${LATEST_TAG#v}
|
|
80
|
+
|
|
81
|
+
# Parse version components
|
|
82
|
+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
|
|
83
|
+
|
|
84
|
+
# Create dev version with commit count since last tag
|
|
85
|
+
COMMIT_COUNT=$(git rev-list --count ${LATEST_TAG}..HEAD 2>/dev/null || echo "1")
|
|
86
|
+
|
|
87
|
+
# Calculate version based on release type from PR labels
|
|
88
|
+
RELEASE_TYPE="${{ steps.pr_labels.outputs.RELEASE_TYPE }}"
|
|
89
|
+
|
|
90
|
+
if [ "$RELEASE_TYPE" = "major" ]; then
|
|
91
|
+
DEV_VERSION="$((MAJOR + 1)).0.0.dev${COMMIT_COUNT}"
|
|
92
|
+
elif [ "$RELEASE_TYPE" = "patch" ]; then
|
|
93
|
+
DEV_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1)).dev${COMMIT_COUNT}"
|
|
94
|
+
else
|
|
95
|
+
# Default to minor
|
|
96
|
+
DEV_VERSION="${MAJOR}.$((MINOR + 1)).0.dev${COMMIT_COUNT}"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
DEV_TAG="v${DEV_VERSION}"
|
|
100
|
+
|
|
101
|
+
echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_OUTPUT
|
|
102
|
+
echo "DEV_TAG=$DEV_TAG" >> $GITHUB_OUTPUT
|
|
103
|
+
echo "📦 Dev version: $DEV_VERSION (based on $RELEASE_TYPE release)"
|
|
104
|
+
|
|
105
|
+
# Create a temporary tag for hatch-vcs
|
|
106
|
+
git config user.name github-actions
|
|
107
|
+
git config user.email github-actions@github.com
|
|
108
|
+
git tag -a "$DEV_TAG" -m "Dev release $DEV_TAG"
|
|
109
|
+
|
|
110
|
+
- name: 📦 Build wheel & sdist
|
|
111
|
+
run: |
|
|
112
|
+
echo "🏷️ Current git state:"
|
|
113
|
+
git describe --tags --always
|
|
114
|
+
echo "📦 Building package..."
|
|
115
|
+
|
|
116
|
+
python -m build --wheel --sdist
|
|
117
|
+
|
|
118
|
+
echo "📦 Build completed. Contents of dist/:"
|
|
119
|
+
ls -la dist/
|
|
120
|
+
|
|
121
|
+
# Verify the version in the built package
|
|
122
|
+
echo "📋 Checking built package version:"
|
|
123
|
+
if ls dist/*.tar.gz 1> /dev/null 2>&1; then
|
|
124
|
+
tar -tf dist/*.tar.gz | grep -E "(PKG-INFO|METADATA)" | head -1 | xargs tar -xOf dist/*.tar.gz | grep "^Version:" || echo "Version not found in metadata"
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
- name: 🧪 Upload to Test PyPI
|
|
128
|
+
uses: pypa/gh-action-pypi-publish@v1.13.0
|
|
129
|
+
with:
|
|
130
|
+
repository-url: https://test.pypi.org/legacy/
|
|
131
|
+
packages-dir: dist
|
|
132
|
+
skip-existing: true
|
|
133
|
+
verbose: true
|
|
134
|
+
|
|
135
|
+
- name: 📝 Create summary
|
|
136
|
+
run: |
|
|
137
|
+
echo "## 🧪 Dev Release Published" >> $GITHUB_STEP_SUMMARY
|
|
138
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
139
|
+
echo "**Version:** \`${{ steps.version.outputs.DEV_VERSION }}\`" >> $GITHUB_STEP_SUMMARY
|
|
140
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
141
|
+
echo "### Installation" >> $GITHUB_STEP_SUMMARY
|
|
142
|
+
echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
|
|
143
|
+
echo "pip install -i https://test.pypi.org/simple/ strapi-kit==${{ steps.version.outputs.DEV_VERSION }}" >> $GITHUB_STEP_SUMMARY
|
|
144
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
145
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
146
|
+
echo "### Changes" >> $GITHUB_STEP_SUMMARY
|
|
147
|
+
echo "Published from commit: \`$(git rev-parse --short HEAD)\`" >> $GITHUB_STEP_SUMMARY
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'docs/**'
|
|
8
|
+
- 'src/strapi_kit/**'
|
|
9
|
+
- 'README.md'
|
|
10
|
+
- 'pyproject.toml'
|
|
11
|
+
- 'mkdocs.yml'
|
|
12
|
+
- '.github/workflows/document.yml'
|
|
13
|
+
pull_request:
|
|
14
|
+
branches: [main]
|
|
15
|
+
paths:
|
|
16
|
+
- 'docs/**'
|
|
17
|
+
- 'src/strapi_kit/**'
|
|
18
|
+
- 'README.md'
|
|
19
|
+
- 'pyproject.toml'
|
|
20
|
+
- 'mkdocs.yml'
|
|
21
|
+
- '.github/workflows/document.yml'
|
|
22
|
+
workflow_dispatch:
|
|
23
|
+
|
|
24
|
+
permissions:
|
|
25
|
+
contents: read
|
|
26
|
+
pages: write
|
|
27
|
+
id-token: write
|
|
28
|
+
|
|
29
|
+
env:
|
|
30
|
+
PYTHON_VERSION: "3.12"
|
|
31
|
+
|
|
32
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
33
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
34
|
+
concurrency:
|
|
35
|
+
group: "pages"
|
|
36
|
+
cancel-in-progress: false
|
|
37
|
+
|
|
38
|
+
jobs:
|
|
39
|
+
build-docs:
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v6
|
|
43
|
+
with:
|
|
44
|
+
fetch-depth: 0
|
|
45
|
+
|
|
46
|
+
- uses: actions/setup-python@v6
|
|
47
|
+
with:
|
|
48
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
49
|
+
|
|
50
|
+
- name: Install uv
|
|
51
|
+
uses: astral-sh/setup-uv@v7
|
|
52
|
+
with:
|
|
53
|
+
enable-cache: true
|
|
54
|
+
|
|
55
|
+
- name: Cache uv dependencies
|
|
56
|
+
uses: actions/cache@v5
|
|
57
|
+
with:
|
|
58
|
+
path: |
|
|
59
|
+
~/.cache/uv
|
|
60
|
+
~/.local/share/uv
|
|
61
|
+
key: ${{ runner.os }}-docs-${{ hashFiles('**/pyproject.toml', 'uv.lock') }}
|
|
62
|
+
restore-keys: |
|
|
63
|
+
${{ runner.os }}-docs-
|
|
64
|
+
|
|
65
|
+
- name: Install dependencies
|
|
66
|
+
run: |
|
|
67
|
+
echo "🚀 Installing with uv"
|
|
68
|
+
uv --version
|
|
69
|
+
|
|
70
|
+
# Generate lock file if it doesn't exist (it's gitignored)
|
|
71
|
+
if [ ! -f "uv.lock" ]; then
|
|
72
|
+
echo "📦 Generating uv.lock file"
|
|
73
|
+
uv lock
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# Install project with docs dependencies
|
|
77
|
+
uv sync --extra docs
|
|
78
|
+
|
|
79
|
+
# Install git for version detection
|
|
80
|
+
echo "📦 Installing git and hatchling for versioning"
|
|
81
|
+
uv pip install hatchling hatch-vcs
|
|
82
|
+
|
|
83
|
+
- name: Get package version
|
|
84
|
+
id: version
|
|
85
|
+
run: |
|
|
86
|
+
echo "📦 Getting package version"
|
|
87
|
+
VERSION=$(uv run python -c "import strapi_kit; print(strapi_kit.__version__)")
|
|
88
|
+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
89
|
+
echo "Package version: $VERSION"
|
|
90
|
+
|
|
91
|
+
- name: Build documentation
|
|
92
|
+
run: |
|
|
93
|
+
echo "📚 Building documentation with version ${{ steps.version.outputs.VERSION }}"
|
|
94
|
+
PACKAGE_VERSION="${{ steps.version.outputs.VERSION }}" uv run mkdocs build --strict
|
|
95
|
+
|
|
96
|
+
- name: Upload Pages artifact
|
|
97
|
+
uses: actions/upload-pages-artifact@v4
|
|
98
|
+
with:
|
|
99
|
+
path: site
|
|
100
|
+
|
|
101
|
+
- name: Generate docs summary
|
|
102
|
+
run: |
|
|
103
|
+
echo "## 📚 Documentation Build" >> $GITHUB_STEP_SUMMARY
|
|
104
|
+
echo "| Item | Value |" >> $GITHUB_STEP_SUMMARY
|
|
105
|
+
echo "|------|-------|" >> $GITHUB_STEP_SUMMARY
|
|
106
|
+
echo "| **Tool** | uv |" >> $GITHUB_STEP_SUMMARY
|
|
107
|
+
echo "| **Event** | ${{ github.event_name }} |" >> $GITHUB_STEP_SUMMARY
|
|
108
|
+
echo "| **Branch** | ${{ github.ref_name }} |" >> $GITHUB_STEP_SUMMARY
|
|
109
|
+
|
|
110
|
+
if [ -d "site" ]; then
|
|
111
|
+
site_size=$(du -sh site | cut -f1)
|
|
112
|
+
echo "| **Site Size** | $site_size |" >> $GITHUB_STEP_SUMMARY
|
|
113
|
+
echo "| **Status** | ✅ Built successfully |" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
else
|
|
115
|
+
echo "| **Status** | ❌ Build failed |" >> $GITHUB_STEP_SUMMARY
|
|
116
|
+
fi
|
|
117
|
+
|
|
118
|
+
deploy-docs:
|
|
119
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
120
|
+
needs: build-docs
|
|
121
|
+
runs-on: ubuntu-latest
|
|
122
|
+
environment:
|
|
123
|
+
name: github-pages
|
|
124
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
125
|
+
steps:
|
|
126
|
+
- name: Deploy to GitHub Pages
|
|
127
|
+
id: deployment
|
|
128
|
+
uses: actions/deploy-pages@v4
|
|
129
|
+
|
|
130
|
+
- name: Generate deployment summary
|
|
131
|
+
run: |
|
|
132
|
+
echo "## 🚀 Documentation Deployed" >> $GITHUB_STEP_SUMMARY
|
|
133
|
+
echo "Documentation has been successfully deployed to GitHub Pages." >> $GITHUB_STEP_SUMMARY
|
|
134
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
135
|
+
echo "🔗 **[View Documentation](${{ steps.deployment.outputs.page_url }})**" >> $GITHUB_STEP_SUMMARY
|
|
136
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
137
|
+
echo "### Quick Links" >> $GITHUB_STEP_SUMMARY
|
|
138
|
+
echo "- [Installation Guide](${{ steps.deployment.outputs.page_url }}installation/)" >> $GITHUB_STEP_SUMMARY
|
|
139
|
+
echo "- [Quickstart](${{ steps.deployment.outputs.page_url }}quickstart/)" >> $GITHUB_STEP_SUMMARY
|
|
140
|
+
echo "- [Configuration](${{ steps.deployment.outputs.page_url }}configuration/)" >> $GITHUB_STEP_SUMMARY
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# .github/workflows/guard-main-origin.yml
|
|
2
|
+
name: Guard-Main-Origin
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [main] # PRs whose *target* is main only
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
pull-requests: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
ensure-valid-origin:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check if PR is from allowed branch
|
|
17
|
+
env:
|
|
18
|
+
BRANCH: ${{ github.head_ref }}
|
|
19
|
+
run: |
|
|
20
|
+
# Allow PRs from dev, hotfix, or updates branches
|
|
21
|
+
if [[ "$BRANCH" == "dev" ]] || [[ "$BRANCH" =~ ^hotfix-.* ]] || [[ "$BRANCH" =~ ^updates-.* ]]; then
|
|
22
|
+
echo "✅ Origin branch '$BRANCH' is allowed"
|
|
23
|
+
else
|
|
24
|
+
echo "::error::Main only accepts PRs from 'dev', 'hotfix-*', or 'updates-*' branches. Current branch: $BRANCH"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|