Skip to content
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

Automatic publishing on PyPI on new release #77

Merged
merged 16 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update Version, Test, Publish to PyPI, and Upload Release Artifacts

on:
release:
types: [created, edited]

jobs:
build-test-publish-upload:
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Set release version
run: |
# Get the tag from the GitHub release
TAG=${GITHUB_REF#refs/tags/}
# Remove 'v' prefix if present
VERSION=${TAG#v}
hatch version $VERSION
- name: Build package
run: hatch build
- name: Run tests
run: hatch run test:pytest
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Verify PyPI Release
run: |
# Verify PyPI release
PACKAGE_NAME="mesa_frames"
CURRENT_VERSION=$(hatch version)
pip install $PACKAGE_NAME==$CURRENT_VERSION
python -c "import mesa_frames; print(mesa_frames.__version__)"
- name: Update to Next Version
adamamer20 marked this conversation as resolved.
Show resolved Hide resolved
run: |
# Bump to next development version
hatch version patch
hatch version dev

# Get the new version
NEW_VERSION=$(hatch version)

# Commit and push the version bump
git config user.name github-actions
git config user.email [email protected]
git add mesa-frames/__init__.py
git commit -m "Bump version to $NEW_VERSION [skip ci]"
git push
2 changes: 2 additions & 0 deletions mesa_frames/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ def __init__(self, width, height):
"GridPandas",
"GridPolars",
]

__version__ = "0.1.0alpha"
68 changes: 53 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,56 @@ build-backend = "hatchling.build"

[project]
name = "mesa_frames"
version = "0.1.0-alpha1"
description = "An extension to the Mesa framework which uses pandas/Polars DataFrames for enhanced performance"
authors = [
{ name = "Adam Amer" },
{ name = "Adam Amer"},
]
license = { text = "MIT" }
readme = "README.md"
keywords = [
"simulation",
"simulation-environment",
"gis",
"pandas",
"simulation-framework",
"agent-based-modeling",
"complex-systems",
"spatial-models",
"mesa",
"complexity-analysis",
"modeling-agents",
"agent-based-modelling"
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Life",
]
dependencies = [
"numpy~=1.26",
"typing-extensions>=4.9" #typing-extensions.Self added in 4.9
]

[project.optional-dependencies]
pandas = [
"pandas~=2.2",
"pyarrow",
"typing-extensions>=4.9", #typing-extensions.Self added in 4.9
## pandas
"pandas>=2.2",
"pyarrow", #for conversion to pandas
#"geopandas" (only after GeoGrid / ContinousSpace is implemented)
]
polars = [
## polars
"polars>=1.0.0", #polars._typing (see mesa_frames.types) added in 1.0.0
#"geopolars" (currently in pre-alpha)
]
requires-python = ">=3.8"
dynamic = [
"version"
]



[project.urls]
Documentation = "https://adamamer20.github.io/mesa-frames"
Repository = "https://github.com/adamamer20/mesa-frames.git"

[project.optional-dependencies]
mkdocs = [
"mkdocs-material",
"mkdocs-jupyter",
Expand All @@ -44,26 +72,35 @@ sphinx = [
]

docs = [
"mesa_frames[pandas, polars, mkdocs, sphinx]",
"mesa_frames[mkdocs, sphinx]",
# Readme Script
"perfplot",
"seaborn"
]

dev = [
"mesa_frames[pandas, polars, docs]",
test = [
"pytest",
"pytest-cov",
"typeguard",
]

dev = [
"mesa_frames[test, docs]",
"mesa",
]

[tool.hatch.envs.test]
features = ["test"]

[tool.hatch.envs.dev] #Allows installing dev as virtual env
features = ["dev"]

[tool.hatch.build.targets.wheel]
packages = ["mesa_frames"]

[tool.hatch.version]
path = "mesa_frames/__init__.py"

[tool.ruff.lint]
select = ["D"]
ignore = ["D101", "D102", "D105"]
Expand All @@ -74,4 +111,5 @@ convention = "numpy"
[tool.ruff.lint.per-file-ignores]
"tests/*" = ["D"]
"examples/*" = ["D"]
"docs/*" = ["D"]
"docs/*" = ["D"]