Check for new mlir-aie release #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # SPDX-FileCopyrightText: Copyright (C) 2025 Advanced Micro Devices, Inc. All rights reserved. | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Check for new mlir-aie release | |
| on: | |
| workflow_dispatch: # Allow manual triggering | |
| schedule: | |
| - cron: '0 10 * * *' # Run every day at 10 AM UTC (3 AM Mountain) | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: write | |
| jobs: | |
| check-and-update: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: devel | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.x' | |
| - name: Get current mlir-aie version | |
| id: current_version | |
| run: | | |
| version=$(grep 'mlir_aie==' requirements.txt | cut -d'=' -f3) | |
| echo "Current version: $version" | |
| echo "version=$version" >> $GITHUB_OUTPUT | |
| - name: Get latest mlir-aie release | |
| id: latest_release | |
| run: | | |
| latest_tag_with_v=$(curl -s "https://api.github.com/repos/Xilinx/mlir-aie/releases/latest" | jq -r '.tag_name') | |
| latest_tag="${latest_tag_with_v#v}" | |
| echo "Latest tag: $latest_tag" | |
| echo "tag_with_v=$latest_tag_with_v" >> $GITHUB_OUTPUT | |
| echo "tag=$latest_tag" >> $GITHUB_OUTPUT | |
| - name: Compare versions and create PR | |
| if: steps.current_version.outputs.version != steps.latest_release.outputs.tag | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo "New version found: ${{ steps.latest_release.outputs.tag_with_v }}. Current version is v${{ steps.current_version.outputs.version }}." | |
| new_branch="update-mlir-aie-to-${{ steps.latest_release.outputs.tag_with_v }}" | |
| # Check if branch already exists | |
| if git ls-remote --exit-code origin "refs/heads/$new_branch"; then | |
| echo "Branch $new_branch already exists. Skipping update." | |
| exit 0 | |
| fi | |
| # Configure git | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
| # Create new branch | |
| git checkout -b $new_branch | |
| # Update requirements.txt | |
| sed -i "s|==${{ steps.current_version.outputs.version }}|==${{ steps.latest_release.outputs.tag }}|" requirements.txt | |
| sed -i "s|mlir-aie/releases/expanded_assets/.*|mlir-aie/releases/expanded_assets/${{ steps.latest_release.outputs.tag_with_v }}|" requirements.txt | |
| # Commit changes | |
| git add requirements.txt | |
| git commit -m "Update mlir-aie to version ${{ steps.latest_release.outputs.tag_with_v }}" | |
| # Push changes | |
| git push --set-upstream origin $new_branch | |
| # Create Pull Request | |
| sed 's/Describe the intent of your PR here./This PR updates the mlir-aie version from v${{ steps.current_version.outputs.version }} to the latest release, ${{ steps.latest_release.outputs.tag_with_v }}./' .github/PULL_REQUEST_TEMPLATE.md | \ | |
| gh pr create \ | |
| --base devel \ | |
| --head $new_branch \ | |
| --title "Update mlir-aie from v${{ steps.current_version.outputs.version }} to ${{ steps.latest_release.outputs.tag_with_v }}" \ | |
| --body-file - | |
| # Trigger CI workflows | |
| echo "Triggering CI workflows..." | |
| gh workflow run ci-lint.yml --ref $new_branch | |
| gh workflow run small.yml --ref $new_branch | |
| gh workflow run test-examples.yml --ref $new_branch | |
| - name: No new version found | |
| if: steps.current_version.outputs.version == steps.latest_release.outputs.tag | |
| run: echo "mlir-aie is already at the latest version (${{ steps.current_version.outputs.version }})." |