|
| 1 | +name: Sync MLX |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 6 * * 1' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-mlx: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + submodules: recursive |
| 20 | + |
| 21 | + - name: Determine MLX release state |
| 22 | + id: mlx |
| 23 | + run: | |
| 24 | + git submodule update --init --recursive extern/mlx |
| 25 | + git -C extern/mlx fetch --tags origin |
| 26 | +
|
| 27 | + LATEST_TAG=$(git -C extern/mlx for-each-ref --sort=-version:refname --format='%(refname:strip=2)' refs/tags | grep '^v' | head -n 1) |
| 28 | + if [ -z "$LATEST_TAG" ]; then |
| 29 | + echo "::error::Failed to determine latest MLX tag" |
| 30 | + exit 1 |
| 31 | + fi |
| 32 | +
|
| 33 | + CURRENT_TAG=$(git -C extern/mlx describe --tags --abbrev=0 2>/dev/null || echo "") |
| 34 | +
|
| 35 | + echo "latest_tag=${LATEST_TAG}" >> "$GITHUB_OUTPUT" |
| 36 | + echo "current_tag=${CURRENT_TAG}" >> "$GITHUB_OUTPUT" |
| 37 | + echo "latest_version=${LATEST_TAG#v}" >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + if [ "$CURRENT_TAG" = "$LATEST_TAG" ]; then |
| 40 | + echo "MLX submodule already at ${CURRENT_TAG}" |
| 41 | + echo "update_needed=false" >> "$GITHUB_OUTPUT" |
| 42 | + else |
| 43 | + echo "MLX update required: ${CURRENT_TAG:-unknown} -> ${LATEST_TAG}" |
| 44 | + echo "update_needed=true" >> "$GITHUB_OUTPUT" |
| 45 | + fi |
| 46 | +
|
| 47 | + - name: Update MLX submodule |
| 48 | + if: steps.mlx.outputs.update_needed == 'true' |
| 49 | + run: | |
| 50 | + git -C extern/mlx checkout ${{ steps.mlx.outputs.latest_tag }} |
| 51 | + git add extern/mlx |
| 52 | +
|
| 53 | + - name: Update package versions |
| 54 | + if: steps.mlx.outputs.update_needed == 'true' |
| 55 | + env: |
| 56 | + VERSION: ${{ steps.mlx.outputs.latest_version }} |
| 57 | + run: | |
| 58 | + python <<'PY' |
| 59 | +import os |
| 60 | +import re |
| 61 | +from pathlib import Path |
| 62 | + |
| 63 | +version = os.environ["VERSION"] |
| 64 | +props_path = Path("Directory.Build.props") |
| 65 | +text = props_path.read_text() |
| 66 | +text = re.sub(r"<Version>[^<]+</Version>", f"<Version>{version}</Version>", text) |
| 67 | +text = re.sub(r"<PackageVersion>[^<]+</PackageVersion>", f"<PackageVersion>{version}</PackageVersion>", text) |
| 68 | +props_path.write_text(text) |
| 69 | +PY |
| 70 | + git add Directory.Build.props |
| 71 | + - name: Setup .NET |
| 72 | + if: steps.mlx.outputs.update_needed == 'true' |
| 73 | + uses: actions/setup-dotnet@v4 |
| 74 | + with: |
| 75 | + dotnet-version: 9.0.x |
| 76 | + |
| 77 | + - name: Build solution |
| 78 | + if: steps.mlx.outputs.update_needed == 'true' |
| 79 | + run: | |
| 80 | + dotnet restore |
| 81 | + dotnet build --configuration Release --no-restore |
| 82 | +
|
| 83 | + - name: Prepare PR |
| 84 | + if: steps.mlx.outputs.update_needed == 'true' |
| 85 | + run: | |
| 86 | + git status -s |
| 87 | +
|
| 88 | + - name: Create pull request |
| 89 | + if: steps.mlx.outputs.update_needed == 'true' |
| 90 | + uses: peter-evans/create-pull-request@v6 |
| 91 | + with: |
| 92 | + branch: chore/sync-mlx-${{ steps.mlx.outputs.latest_version }} |
| 93 | + commit-message: chore: sync MLX to ${{ steps.mlx.outputs.latest_tag }} |
| 94 | + title: chore: sync MLX to ${{ steps.mlx.outputs.latest_tag }} |
| 95 | + body: | |
| 96 | + - Update `extern/mlx` submodule to `${{ steps.mlx.outputs.latest_tag }}` |
| 97 | + - Align package version fields to `${{ steps.mlx.outputs.latest_version }}` |
| 98 | + signoff: false |
0 commit comments