|
49 | 49 | name: cogames-dist |
50 | 50 | path: dist/* |
51 | 51 |
|
| 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 | +
|
52 | 109 | publish: |
53 | 110 | name: Publish to PyPI |
54 | | - needs: build |
| 111 | + needs: wait-for-mettagrid |
55 | 112 | if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.publish == 'yes' }} |
56 | 113 | runs-on: ubuntu-latest |
57 | 114 | environment: |
|
0 commit comments