Skip to content

Commit 0d7d5b6

Browse files
committed
feat: wait for mettagrid PyPi release before publishing cogames to PyPi
1 parent 8a1f72d commit 0d7d5b6

File tree

3 files changed

+61
-4
lines changed

3 files changed

+61
-4
lines changed

.github/workflows/release-cogames.yml

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,66 @@ jobs:
4949
name: cogames-dist
5050
path: dist/*
5151

52+
wait-for-mettagrid:
53+
name: Wait for mettagrid on PyPI
54+
needs: build
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
ref: ${{ github.ref }}
60+
fetch-depth: 0
61+
fetch-tags: true
62+
63+
- name: Extract mettagrid version requirement
64+
id: version
65+
run: |
66+
# Parse packages/cogames/pyproject.toml to find mettagrid==X.Y.Z or mettagrid>=X.Y.Z
67+
if grep -qE 'mettagrid[><=~!]' packages/cogames/pyproject.toml; then
68+
VERSION=$(grep -E 'mettagrid' packages/cogames/pyproject.toml | grep -oP '\d+\.\d+\.\d+(\.\d+)?' | head -1)
69+
echo "mettagrid_version=$VERSION" >> $GITHUB_OUTPUT
70+
echo "Found mettagrid version requirement: $VERSION"
71+
else
72+
echo "No mettagrid version found - skipping wait"
73+
echo "mettagrid_version=" >> $GITHUB_OUTPUT
74+
fi
75+
76+
- name: Wait for mettagrid on PyPI
77+
if: steps.version.outputs.mettagrid_version != ''
78+
env:
79+
VERSION: ${{ steps.version.outputs.mettagrid_version }}
80+
PYPI_URL: 'https://pypi.org'
81+
run: |
82+
# Timing rationale:
83+
# - mettagrid's build job takes ~5 minutes
84+
# - PyPI propagation might add a few minutes
85+
# - Add some buffer just in case
86+
# Total: 10 minutes should be sufficient
87+
MAX_WAIT=600 # 10 minutes total
88+
CHECK_INTERVAL=60 # Check every minute
89+
ELAPSED=0
90+
91+
echo "Waiting for mettagrid==$VERSION to be available on $PYPI_URL..."
92+
echo "This ensures cogames can be installed with its pinned mettagrid dependency."
93+
echo ""
94+
95+
while [ $ELAPSED -lt $MAX_WAIT ]; do
96+
if curl -sf "$PYPI_URL/pypi/mettagrid/$VERSION/json" > /dev/null 2>&1; then
97+
echo "✓ mettagrid $VERSION is available on $PYPI_URL!"
98+
exit 0
99+
fi
100+
echo "⏳ Waiting... ($ELAPSED/$MAX_WAIT seconds elapsed)"
101+
sleep $CHECK_INTERVAL
102+
ELAPSED=$((ELAPSED + CHECK_INTERVAL))
103+
done
104+
105+
echo "❌ ERROR: mettagrid $VERSION not found on $PYPI_URL after $MAX_WAIT seconds"
106+
echo "The mettagrid release workflow may have failed or is taking longer than expected."
107+
exit 1
108+
52109
publish:
53110
name: Publish to PyPI
54-
needs: build
111+
needs: wait-for-mettagrid
55112
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish == 'yes' }}
56113
runs-on: ubuntu-latest
57114
environment:

packages/cogames/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "README.md"
99
requires-python = ">=3.12,<3.13"
1010
dependencies = [
1111
"heavyball>=2.0.0",
12-
"mettagrid",
12+
"mettagrid==0.2.0.99",
1313
"packaging>=24.0.0",
1414
"pufferlib-core",
1515
"pydantic>=2.11.5",
@@ -40,7 +40,7 @@ cogames = ["py.typed", "maps/*.map", "maps/**/*.map", "assets/**/*"]
4040
[tool.setuptools_scm]
4141
tag_regex = "^cogames-v(?P<version>\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)$"
4242
version_scheme = "no-guess-dev"
43-
local_scheme = "node-and-date"
43+
local_scheme = "no-local-version"
4444
root = "../.."
4545
fallback_version = "0.0.0"
4646
# Provide a specific git command to be used in order to find the correct versioning tags

packages/mettagrid/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ demo = "mettagrid.demo:main"
8484
[tool.setuptools_scm]
8585
tag_regex = "^mettagrid-v(?P<version>\\d+\\.\\d+\\.\\d+(?:\\.\\d+)?)$"
8686
version_scheme = "no-guess-dev"
87-
local_scheme = "node-and-date"
87+
local_scheme = "no-local-version"
8888
root = "../.."
8989
fallback_version = "0.0.0"
9090
# Provide a specific git command to be used in order to find the correct versioning tags

0 commit comments

Comments
 (0)