Skip to content

Commit 73eae6d

Browse files
Automatic publishing on PyPI on new release (#77)
* adding version to __init__.py * add publishing GH Action * updating pyproject.toml * updating the GH Action * Revert "updating the GH Action" This reverts commit 34689a0. * updating dependencies * updating dependencies on documentation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * adding edited to yml * pypa publishing action * fix: mesa-frames version * fix: add version to dynamic * fix topic * adding creation of version branch --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 98af5c8 commit 73eae6d

File tree

3 files changed

+134
-15
lines changed

3 files changed

+134
-15
lines changed

.github/workflows/publish.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Update Version, Test, Publish to PyPI, and Upload Release Artifacts
2+
3+
on:
4+
release:
5+
types: [created, edited]
6+
7+
jobs:
8+
build-test-publish-upload:
9+
runs-on: ubuntu-latest
10+
environment: release
11+
permissions:
12+
# IMPORTANT: this permission is mandatory for trusted publishing
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: '3.x'
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install hatch
26+
- name: Set release version
27+
run: |
28+
# Get the tag from the GitHub release
29+
TAG=${GITHUB_REF#refs/tags/}
30+
# Remove 'v' prefix if present
31+
VERSION=${TAG#v}
32+
hatch version $VERSION
33+
- name: Build package
34+
run: hatch build
35+
- name: Run tests
36+
run: hatch run test:pytest
37+
- name: Publish package to PyPI
38+
uses: pypa/gh-action-pypi-publish@release/v1
39+
- name: Verify PyPI Release
40+
run: |
41+
# Verify PyPI release
42+
PACKAGE_NAME="mesa_frames"
43+
CURRENT_VERSION=$(hatch version)
44+
pip install $PACKAGE_NAME==$CURRENT_VERSION
45+
python -c "import mesa_frames; print(mesa_frames.__version__)"
46+
- name: Create or recreate version branch
47+
- name: Create or recreate version branch
48+
run: |
49+
CURRENT_VERSION=$(hatch version)
50+
BRANCH_NAME="v$CURRENT_VERSION"
51+
52+
git config user.name github-actions
53+
git config user.email github-actions@github.com
54+
55+
# Delete the branch if it exists (both locally and remotely)
56+
git branch -D $BRANCH_NAME || true
57+
git push origin --delete $BRANCH_NAME || true
58+
59+
# Create and push the new branch
60+
git checkout -b $BRANCH_NAME
61+
git push -u origin $BRANCH_NAME
62+
63+
# Switch back to the main branch
64+
git checkout main
65+
- name: Update to Next Version
66+
run: |
67+
# Bump to next development version
68+
hatch version patch
69+
hatch version dev
70+
71+
# Get the new version
72+
NEW_VERSION=$(hatch version)
73+
74+
# Commit and push the version bump
75+
git config user.name github-actions
76+
git config user.email github-actions@github.com
77+
git add mesa-frames/__init__.py
78+
git commit -m "Bump version to $NEW_VERSION [skip ci]"
79+
git push

mesa_frames/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ def __init__(self, width, height):
5757
"GridPandas",
5858
"GridPolars",
5959
]
60+
61+
__version__ = "0.1.0alpha"

pyproject.toml

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,56 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "mesa_frames"
7-
version = "0.1.0-alpha1"
87
description = "An extension to the Mesa framework which uses pandas/Polars DataFrames for enhanced performance"
98
authors = [
10-
{ name = "Adam Amer" },
9+
{ name = "Adam Amer"},
1110
]
1211
license = { text = "MIT" }
12+
readme = "README.md"
13+
keywords = [
14+
"simulation",
15+
"simulation-environment",
16+
"gis",
17+
"pandas",
18+
"simulation-framework",
19+
"agent-based-modeling",
20+
"complex-systems",
21+
"spatial-models",
22+
"mesa",
23+
"complexity-analysis",
24+
"modeling-agents",
25+
"agent-based-modelling"
26+
]
27+
classifiers = [
28+
"Development Status :: 3 - Alpha",
29+
"Intended Audience :: Science/Research",
30+
"License :: OSI Approved :: MIT License",
31+
"Programming Language :: Python :: 3",
32+
"Topic :: Scientific/Engineering :: Artificial Life",
33+
]
1334
dependencies = [
1435
"numpy~=1.26",
15-
"typing-extensions>=4.9" #typing-extensions.Self added in 4.9
16-
]
17-
18-
[project.optional-dependencies]
19-
pandas = [
20-
"pandas~=2.2",
21-
"pyarrow",
36+
"typing-extensions>=4.9", #typing-extensions.Self added in 4.9
37+
## pandas
38+
"pandas>=2.2",
39+
"pyarrow", #for conversion to pandas
2240
#"geopandas" (only after GeoGrid / ContinousSpace is implemented)
23-
]
24-
polars = [
41+
## polars
2542
"polars>=1.0.0", #polars._typing (see mesa_frames.types) added in 1.0.0
2643
#"geopolars" (currently in pre-alpha)
2744
]
45+
requires-python = ">=3.8"
46+
dynamic = [
47+
"version"
48+
]
49+
50+
2851

52+
[project.urls]
53+
Documentation = "https://adamamer20.github.io/mesa-frames"
54+
Repository = "https://github.com/adamamer20/mesa-frames.git"
55+
56+
[project.optional-dependencies]
2957
mkdocs = [
3058
"mkdocs-material",
3159
"mkdocs-jupyter",
@@ -44,26 +72,35 @@ sphinx = [
4472
]
4573

4674
docs = [
47-
"mesa_frames[pandas, polars, mkdocs, sphinx]",
75+
"mesa_frames[mkdocs, sphinx]",
4876
# Readme Script
4977
"perfplot",
5078
"seaborn"
5179
]
5280

53-
dev = [
54-
"mesa_frames[pandas, polars, docs]",
81+
test = [
5582
"pytest",
5683
"pytest-cov",
5784
"typeguard",
85+
]
86+
87+
dev = [
88+
"mesa_frames[test, docs]",
5889
"mesa",
5990
]
6091

92+
[tool.hatch.envs.test]
93+
features = ["test"]
94+
6195
[tool.hatch.envs.dev] #Allows installing dev as virtual env
6296
features = ["dev"]
6397

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

101+
[tool.hatch.version]
102+
path = "mesa_frames/__init__.py"
103+
67104
[tool.ruff.lint]
68105
select = ["D"]
69106
ignore = ["D101", "D102", "D105"]
@@ -74,4 +111,5 @@ convention = "numpy"
74111
[tool.ruff.lint.per-file-ignores]
75112
"tests/*" = ["D"]
76113
"examples/*" = ["D"]
77-
"docs/*" = ["D"]
114+
"docs/*" = ["D"]
115+

0 commit comments

Comments
 (0)