|
| 1 | +name: Update Versions |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run weekly on Monday at 9am UTC |
| 6 | + - cron: '0 9 * * 1' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + rust_version: |
| 10 | + description: 'Rust version (leave empty to auto-detect)' |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + llvm_version: |
| 14 | + description: 'LLVM version for Windows (leave empty to auto-detect)' |
| 15 | + required: false |
| 16 | + type: string |
| 17 | + git_version: |
| 18 | + description: 'Git for Windows version (leave empty to auto-detect)' |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + 7zip_version: |
| 22 | + description: '7-Zip version code e.g. 2600 (leave empty to auto-detect)' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + |
| 26 | +permissions: |
| 27 | + contents: write |
| 28 | + pull-requests: write |
| 29 | + |
| 30 | +jobs: |
| 31 | + check-updates: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + outputs: |
| 34 | + rust_current: ${{ steps.current.outputs.rust }} |
| 35 | + rust_latest: ${{ steps.latest.outputs.rust }} |
| 36 | + llvm_current: ${{ steps.current.outputs.llvm }} |
| 37 | + llvm_latest: ${{ steps.latest.outputs.llvm }} |
| 38 | + llvm_major: ${{ steps.latest.outputs.llvm_major }} |
| 39 | + git_current: ${{ steps.current.outputs.git }} |
| 40 | + git_latest: ${{ steps.latest.outputs.git }} |
| 41 | + 7zip_current: ${{ steps.current.outputs.7zip }} |
| 42 | + 7zip_latest: ${{ steps.latest.outputs.7zip }} |
| 43 | + has_update: ${{ steps.compare.outputs.has_update }} |
| 44 | + update_summary: ${{ steps.compare.outputs.summary }} |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v4 |
| 47 | + |
| 48 | + - name: Get current versions from Dockerfiles |
| 49 | + id: current |
| 50 | + run: | |
| 51 | + # Get from linux/Dockerfile |
| 52 | + RUST=$(grep -oP 'RUST_VERSION=\K[0-9.]+' linux/Dockerfile | head -1) |
| 53 | + LLVM_MAJOR=$(grep -oP 'LLVM_VERSION=\K[0-9]+' linux/Dockerfile | head -1) |
| 54 | + |
| 55 | + # Get from windows/Dockerfile (full LLVM version) |
| 56 | + LLVM=$(grep -oP 'LLVM_VERSION=\K[0-9.]+' windows/Dockerfile | head -1) |
| 57 | + GIT=$(grep -oP 'GIT_VERSION=\K[0-9.]+' windows/Dockerfile | head -1) |
| 58 | + ZIP=$(grep -oP '7ZIP_VERSION=\K[0-9]+' windows/Dockerfile | head -1) |
| 59 | + |
| 60 | + echo "rust=$RUST" >> $GITHUB_OUTPUT |
| 61 | + echo "llvm=$LLVM" >> $GITHUB_OUTPUT |
| 62 | + echo "llvm_major=$LLVM_MAJOR" >> $GITHUB_OUTPUT |
| 63 | + echo "git=$GIT" >> $GITHUB_OUTPUT |
| 64 | + echo "7zip=$ZIP" >> $GITHUB_OUTPUT |
| 65 | + |
| 66 | + echo "Current versions:" |
| 67 | + echo " Rust: $RUST" |
| 68 | + echo " LLVM: $LLVM (major: $LLVM_MAJOR)" |
| 69 | + echo " Git: $GIT" |
| 70 | + echo " 7-Zip: $ZIP" |
| 71 | +
|
| 72 | + - name: Get latest versions |
| 73 | + id: latest |
| 74 | + env: |
| 75 | + GH_TOKEN: ${{ github.token }} |
| 76 | + run: | |
| 77 | + # Rust - from official manifest |
| 78 | + if [ -n "${{ inputs.rust_version }}" ]; then |
| 79 | + RUST="${{ inputs.rust_version }}" |
| 80 | + else |
| 81 | + RUST=$(curl -s https://static.rust-lang.org/dist/channel-rust-stable.toml | grep -oP 'cargo-\K[0-9]+\.[0-9]+\.[0-9]+' | head -1) |
| 82 | + fi |
| 83 | + echo "rust=$RUST" >> $GITHUB_OUTPUT |
| 84 | + echo "Latest Rust: $RUST" |
| 85 | + |
| 86 | + # LLVM - from ghaith/llvm-package-windows releases |
| 87 | + if [ -n "${{ inputs.llvm_version }}" ]; then |
| 88 | + LLVM="${{ inputs.llvm_version }}" |
| 89 | + else |
| 90 | + LLVM=$(gh api repos/ghaith/llvm-package-windows/releases/latest --jq '.tag_name' | sed 's/^v//') |
| 91 | + fi |
| 92 | + LLVM_MAJOR=$(echo "$LLVM" | grep -oP '^\d+') |
| 93 | + echo "llvm=$LLVM" >> $GITHUB_OUTPUT |
| 94 | + echo "llvm_major=$LLVM_MAJOR" >> $GITHUB_OUTPUT |
| 95 | + echo "Latest LLVM: $LLVM (major: $LLVM_MAJOR)" |
| 96 | + |
| 97 | + # Git for Windows - from GitHub releases |
| 98 | + if [ -n "${{ inputs.git_version }}" ]; then |
| 99 | + GIT="${{ inputs.git_version }}" |
| 100 | + else |
| 101 | + GIT=$(gh api repos/git-for-windows/git/releases/latest --jq '.tag_name' | grep -oP '[0-9]+\.[0-9]+\.[0-9]+') |
| 102 | + fi |
| 103 | + echo "git=$GIT" >> $GITHUB_OUTPUT |
| 104 | + echo "Latest Git: $GIT" |
| 105 | + |
| 106 | + # 7-Zip - scrape from download page (version code like 2600 for 26.00) |
| 107 | + if [ -n "${{ inputs.7zip_version }}" ]; then |
| 108 | + ZIP="${{ inputs.7zip_version }}" |
| 109 | + else |
| 110 | + ZIP=$(curl -s https://www.7-zip.org/download.html | grep -oP '7z\K[0-9]{4}(?=-x64\.exe)' | head -1) |
| 111 | + fi |
| 112 | + echo "7zip=$ZIP" >> $GITHUB_OUTPUT |
| 113 | + echo "Latest 7-Zip: $ZIP" |
| 114 | +
|
| 115 | + - name: Compare versions |
| 116 | + id: compare |
| 117 | + run: | |
| 118 | + UPDATES="" |
| 119 | + HAS_UPDATE=false |
| 120 | + |
| 121 | + if [ "${{ steps.current.outputs.rust }}" != "${{ steps.latest.outputs.rust }}" ]; then |
| 122 | + UPDATES="${UPDATES}- Rust: ${{ steps.current.outputs.rust }} → ${{ steps.latest.outputs.rust }}\n" |
| 123 | + HAS_UPDATE=true |
| 124 | + fi |
| 125 | + |
| 126 | + if [ "${{ steps.current.outputs.llvm }}" != "${{ steps.latest.outputs.llvm }}" ]; then |
| 127 | + UPDATES="${UPDATES}- LLVM: ${{ steps.current.outputs.llvm }} → ${{ steps.latest.outputs.llvm }}\n" |
| 128 | + HAS_UPDATE=true |
| 129 | + fi |
| 130 | + |
| 131 | + if [ "${{ steps.current.outputs.git }}" != "${{ steps.latest.outputs.git }}" ]; then |
| 132 | + UPDATES="${UPDATES}- Git: ${{ steps.current.outputs.git }} → ${{ steps.latest.outputs.git }}\n" |
| 133 | + HAS_UPDATE=true |
| 134 | + fi |
| 135 | + |
| 136 | + if [ "${{ steps.current.outputs.7zip }}" != "${{ steps.latest.outputs.7zip }}" ]; then |
| 137 | + UPDATES="${UPDATES}- 7-Zip: ${{ steps.current.outputs.7zip }} → ${{ steps.latest.outputs.7zip }}\n" |
| 138 | + HAS_UPDATE=true |
| 139 | + fi |
| 140 | + |
| 141 | + if [ "$HAS_UPDATE" = true ]; then |
| 142 | + echo "has_update=true" >> $GITHUB_OUTPUT |
| 143 | + echo -e "Updates available:\n$UPDATES" |
| 144 | + else |
| 145 | + echo "has_update=false" >> $GITHUB_OUTPUT |
| 146 | + echo "All versions are up to date" |
| 147 | + fi |
| 148 | + |
| 149 | + # Store summary for PR body (escape newlines for GitHub Actions) |
| 150 | + echo "summary<<EOF" >> $GITHUB_OUTPUT |
| 151 | + echo -e "$UPDATES" >> $GITHUB_OUTPUT |
| 152 | + echo "EOF" >> $GITHUB_OUTPUT |
| 153 | +
|
| 154 | + create-pr: |
| 155 | + needs: check-updates |
| 156 | + if: needs.check-updates.outputs.has_update == 'true' |
| 157 | + runs-on: ubuntu-latest |
| 158 | + steps: |
| 159 | + - uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: Update versions in Dockerfiles |
| 162 | + run: | |
| 163 | + echo "Applying version updates..." |
| 164 | + |
| 165 | + # Update Rust in both Dockerfiles |
| 166 | + if [ "${{ needs.check-updates.outputs.rust_current }}" != "${{ needs.check-updates.outputs.rust_latest }}" ]; then |
| 167 | + sed -i "s/RUST_VERSION=${{ needs.check-updates.outputs.rust_current }}/RUST_VERSION=${{ needs.check-updates.outputs.rust_latest }}/" linux/Dockerfile windows/Dockerfile |
| 168 | + echo "Updated Rust to ${{ needs.check-updates.outputs.rust_latest }}" |
| 169 | + fi |
| 170 | + |
| 171 | + # Update LLVM in windows/Dockerfile (full version) |
| 172 | + if [ "${{ needs.check-updates.outputs.llvm_current }}" != "${{ needs.check-updates.outputs.llvm_latest }}" ]; then |
| 173 | + sed -i "s/LLVM_VERSION=${{ needs.check-updates.outputs.llvm_current }}/LLVM_VERSION=${{ needs.check-updates.outputs.llvm_latest }}/" windows/Dockerfile |
| 174 | + # Update major version in linux/Dockerfile |
| 175 | + OLD_MAJOR=$(echo "${{ needs.check-updates.outputs.llvm_current }}" | grep -oP '^\d+') |
| 176 | + NEW_MAJOR="${{ needs.check-updates.outputs.llvm_major }}" |
| 177 | + if [ "$OLD_MAJOR" != "$NEW_MAJOR" ]; then |
| 178 | + sed -i "s/LLVM_VERSION=$OLD_MAJOR/LLVM_VERSION=$NEW_MAJOR/" linux/Dockerfile |
| 179 | + echo "Updated Linux LLVM major to $NEW_MAJOR" |
| 180 | + fi |
| 181 | + echo "Updated Windows LLVM to ${{ needs.check-updates.outputs.llvm_latest }}" |
| 182 | + fi |
| 183 | + |
| 184 | + # Update Git in windows/Dockerfile |
| 185 | + if [ "${{ needs.check-updates.outputs.git_current }}" != "${{ needs.check-updates.outputs.git_latest }}" ]; then |
| 186 | + sed -i "s/GIT_VERSION=${{ needs.check-updates.outputs.git_current }}/GIT_VERSION=${{ needs.check-updates.outputs.git_latest }}/" windows/Dockerfile |
| 187 | + echo "Updated Git to ${{ needs.check-updates.outputs.git_latest }}" |
| 188 | + fi |
| 189 | + |
| 190 | + # Update 7-Zip in windows/Dockerfile |
| 191 | + if [ "${{ needs.check-updates.outputs.7zip_current }}" != "${{ needs.check-updates.outputs.7zip_latest }}" ]; then |
| 192 | + sed -i "s/7ZIP_VERSION=${{ needs.check-updates.outputs.7zip_current }}/7ZIP_VERSION=${{ needs.check-updates.outputs.7zip_latest }}/" windows/Dockerfile |
| 193 | + echo "Updated 7-Zip to ${{ needs.check-updates.outputs.7zip_latest }}" |
| 194 | + fi |
| 195 | + |
| 196 | + echo "" |
| 197 | + echo "Updated Dockerfiles:" |
| 198 | + grep -E '(RUST_VERSION|LLVM_VERSION|GIT_VERSION|7ZIP_VERSION)=' linux/Dockerfile windows/Dockerfile |
| 199 | +
|
| 200 | + - name: Generate branch name and tag |
| 201 | + id: meta |
| 202 | + run: | |
| 203 | + # Branch name based on what's being updated |
| 204 | + BRANCH="update-deps" |
| 205 | + |
| 206 | + # Tag is based on LLVM major and Rust major.minor |
| 207 | + LLVM_MAJOR="${{ needs.check-updates.outputs.llvm_major }}" |
| 208 | + RUST="${{ needs.check-updates.outputs.rust_latest }}" |
| 209 | + RUST_MAJOR_MINOR=$(echo "$RUST" | grep -oP '^\d+\.\d+') |
| 210 | + |
| 211 | + TAG="v${LLVM_MAJOR}-${RUST_MAJOR_MINOR}" |
| 212 | + |
| 213 | + echo "branch=$BRANCH" >> $GITHUB_OUTPUT |
| 214 | + echo "tag=$TAG" >> $GITHUB_OUTPUT |
| 215 | + echo "Branch: $BRANCH, Tag: $TAG" |
| 216 | +
|
| 217 | + - name: Create Pull Request |
| 218 | + uses: peter-evans/create-pull-request@v6 |
| 219 | + with: |
| 220 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 221 | + commit-message: "chore: update dependencies" |
| 222 | + title: "Update dependencies" |
| 223 | + body: | |
| 224 | + This PR updates the following dependencies: |
| 225 | + |
| 226 | + ${{ needs.check-updates.outputs.update_summary }} |
| 227 | + |
| 228 | + ## Updated versions |
| 229 | + | Component | Version | |
| 230 | + |-----------|---------| |
| 231 | + | Rust | ${{ needs.check-updates.outputs.rust_latest }} | |
| 232 | + | LLVM (Windows) | ${{ needs.check-updates.outputs.llvm_latest }} | |
| 233 | + | LLVM (Linux) | ${{ needs.check-updates.outputs.llvm_major }} | |
| 234 | + | Git for Windows | ${{ needs.check-updates.outputs.git_latest }} | |
| 235 | + | 7-Zip | ${{ needs.check-updates.outputs.7zip_latest }} | |
| 236 | + |
| 237 | + ## Release |
| 238 | + When merged, this will be tagged as `${{ steps.meta.outputs.tag }}`. |
| 239 | + |
| 240 | + --- |
| 241 | + *This PR was automatically created by the update-versions workflow.* |
| 242 | + branch: ${{ steps.meta.outputs.branch }} |
| 243 | + delete-branch: true |
| 244 | + labels: | |
| 245 | + dependencies |
| 246 | + automated |
0 commit comments