-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add release-please and CI/CD workflows for PyPI publishing #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9fbb2b
feat: add release-please and CI/CD workflows for PyPI publishing
wyrdbound e646fd1
fix: test failures
wyrdbound 2fba828
chore: add uv
wyrdbound 828be24
chore: fix ruff check
wyrdbound 88b1dff
fix: permissions issue in release.yml
wyrdbound ba1a610
fix: mypy failure
wyrdbound File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, develop] | ||
| pull_request: | ||
| branches: [main, develop] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.11", "3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e ".[dev]" | ||
|
|
||
| - name: Run tests with pytest | ||
| run: python -m pytest tests/ -v --tb=short | ||
|
|
||
| code-quality: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e ".[dev]" | ||
|
|
||
| - name: Check code formatting and linting with Ruff | ||
| run: | | ||
| ruff check src/ tests/ | ||
| ruff format --check src/ tests/ | ||
|
|
||
| - name: Type checking with mypy | ||
| run: mypy src/ | ||
|
|
||
| install-test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Test package installation | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install . | ||
|
|
||
| - name: Test basic import | ||
| run: python -c "import grimoire; print('Import successful')" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Release Please | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| release-please: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| release_created: ${{ steps.release.outputs.release_created }} | ||
| tag_name: ${{ steps.release.outputs.tag_name }} | ||
| steps: | ||
| - uses: googleapis/release-please-action@v4 | ||
| id: release | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| config-file: release-please-config.json | ||
| manifest-file: .release-please-manifest.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: Release | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.11", "3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -e ".[dev]" | ||
|
|
||
| - name: Run tests | ||
| run: python -m pytest tests/ -v | ||
|
|
||
| build-and-publish: | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| environment: release | ||
| permissions: | ||
| contents: read | ||
| id-token: write # required for PyPI trusted publishing | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install build dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| ".": "0.0.0" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # GRIMOIRE | ||
|
|
||
| **GRIMOIRE** (Generic Rule Implementation Model for Omniversal Interactive Roleplaying Engines) is a Python library for loading, validating, and working with structured tabletop RPG system definitions. | ||
|
|
||
| It provides a declarative YAML-based specification format for encoding game systems — covering models, flows, tables, compendiums, prompts, and sources — and a Python loader that parses and validates those definitions into typed Python objects. | ||
|
|
||
| GRIMOIRE is system-agnostic and not tied to any particular game or application. It is designed to be used as a foundation for tools that need to reason about RPG rules programmatically: AI game masters, character generators, rule validators, or any application that needs to load and execute structured game logic. | ||
|
|
||
| --- | ||
|
|
||
| ## Installation | ||
|
|
||
| To add to a uv-managed project: | ||
|
|
||
| ```bash | ||
| uv add grimoire-spec | ||
| ``` | ||
|
|
||
| Or to install directly into an environment: | ||
|
|
||
| ```bash | ||
| uv pip install grimoire-spec | ||
| ``` | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```python | ||
| from pathlib import Path | ||
| from grimoire.loader import SystemLoader | ||
|
|
||
| loader = SystemLoader() | ||
| system = loader.load(Path("systems/knave-1e")) | ||
|
|
||
| print(system.name) # "Knave (1st Edition)" | ||
| print(len(system.models)) # number of loaded models | ||
| print(len(system.flows)) # number of loaded flows | ||
|
|
||
| errors = system.validate() | ||
| if not errors: | ||
| print("System is valid") | ||
| ``` | ||
|
|
||
| See the [`examples/`](examples/) directory for more usage patterns. | ||
|
|
||
| ## System Definition Format | ||
|
|
||
| A GRIMOIRE system is a directory containing YAML files organised by type: | ||
|
|
||
| ``` | ||
| my-system/ | ||
| system.yaml # root metadata, currency, attribution | ||
| models/ # data model definitions | ||
| flows/ # rule sequences and game mechanics | ||
| tables/ # random tables | ||
| compendiums/ # item/entity catalogues | ||
| prompts/ # AI prompt templates | ||
| sources/ # source material attribution | ||
| ``` | ||
|
|
||
| Full specification for each file type is in [`spec/`](spec/). | ||
|
|
||
| ## Development | ||
|
|
||
| This project uses [`uv`](https://github.com/astral-sh/uv) for environment and dependency management. | ||
|
|
||
| ### Setup | ||
|
|
||
| ```bash | ||
| uv sync --extra dev | ||
| ``` | ||
|
|
||
| ### Run tests | ||
|
|
||
| ```bash | ||
| uv run pytest | ||
| ``` | ||
|
|
||
| ### Linting and formatting | ||
|
|
||
| ```bash | ||
| uv run ruff check src/ tests/ | ||
| uv run ruff format src/ tests/ | ||
| ``` | ||
|
|
||
| ### Type checking | ||
|
|
||
| ```bash | ||
| uv run mypy src/ | ||
| ``` | ||
|
|
||
| ### Run an example | ||
|
|
||
| ```bash | ||
| uv run python examples/load_system.py | ||
| ``` | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| src/grimoire/ # library source | ||
| loader.py # SystemLoader — entry point for loading a system directory | ||
| models/ # typed Python models for each definition type | ||
| spec/ # YAML format specification documents | ||
| systems/ # bundled example systems (knave-1e, wyrdbound-quickstart-1e) | ||
| examples/ # usage examples | ||
| tests/ # test suite | ||
| ``` | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions are welcome. Please follow the existing code style (enforced by Ruff) and ensure all tests pass before submitting a pull request. New features should be accompanied by tests and an example in `examples/`. | ||
|
|
||
| ## License | ||
|
|
||
| See [LICENSE](LICENSE) for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", | ||
| "release-type": "python", | ||
| "packages": { | ||
| ".": { | ||
| "release-type": "python", | ||
| "package-name": "grimoire-spec", | ||
| "version-file": "pyproject.toml" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.