Skip to content

Commit 730014f

Browse files
committed
feat: add automated version checking and release workflows
- Unify env vars in Windows Dockerfile (RUST_VERSION, LLVM_VERSION, 7ZIP_VERSION) - Add update-versions.yml to check for new Rust, LLVM, Git, and 7-Zip releases - Add release.yml to auto-create releases when version update PRs are merged
1 parent 0f98565 commit 730014f

File tree

3 files changed

+295
-6
lines changed

3 files changed

+295
-6
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
# Only run if PR was merged and was an automated version update
14+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'update-rust-')
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Extract versions for tag
20+
id: version
21+
run: |
22+
RUST=$(grep -oP 'RUST_VERSION=\K[0-9.]+' linux/Dockerfile | head -1)
23+
LLVM=$(grep -oP 'LLVM_VERSION=\K[0-9]+' linux/Dockerfile | head -1)
24+
25+
# Extract major.minor from rust version (e.g., 1.93.1 -> 1.93)
26+
RUST_MAJOR_MINOR=$(echo "$RUST" | grep -oP '^\d+\.\d+')
27+
28+
TAG="v${LLVM}-${RUST_MAJOR_MINOR}"
29+
echo "tag=$TAG" >> $GITHUB_OUTPUT
30+
echo "rust=$RUST" >> $GITHUB_OUTPUT
31+
echo "llvm=$LLVM" >> $GITHUB_OUTPUT
32+
echo "Creating tag: $TAG"
33+
34+
- name: Create Release
35+
uses: softprops/action-gh-release@v2
36+
with:
37+
tag_name: ${{ steps.version.outputs.tag }}
38+
name: ${{ steps.version.outputs.tag }}
39+
body: |
40+
## Versions
41+
- **Rust**: ${{ steps.version.outputs.rust }}
42+
- **LLVM**: ${{ steps.version.outputs.llvm }}
43+
generate_release_notes: true
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
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

windows/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ ARG BASE_IMAGE=mcr.microsoft.com/windows/servercore:$WINDOWS_VERSION
44

55
FROM $BASE_IMAGE
66

7-
ARG LLVM_VER=21.1.7
8-
ARG RUST_VER=1.93.1
9-
ARG ZIP_VERSION=2600
7+
ARG LLVM_VERSION=21.1.7
8+
ARG RUST_VERSION=1.93.1
9+
ARG 7ZIP_VERSION=2600
1010
ARG GIT_VERSION=2.53.0
1111

1212
WORKDIR C:/buildtools
@@ -32,7 +32,7 @@ RUN C:/TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache `
3232
SHELL ["C:\\buildtools\\Common7\\Tools\\VsDevCmd.bat", "&&", "cmd", "/S", "/C"]
3333

3434
ADD https://win.rustup.rs C:/TEMP/rustup-init.exe
35-
RUN C:/TEMP/rustup-init.exe --default-toolchain %RUST_VER% -y `
35+
RUN C:/TEMP/rustup-init.exe --default-toolchain %RUST_VERSION% -y `
3636
&& del /q C:\TEMP\rustup-init.exe
3737

3838
# Set PATH for Rust - VsDevCmd.bat already sets up MSVC paths
@@ -47,7 +47,7 @@ RUN rustup component add llvm-tools-preview
4747
# STAGE 3: Install additional tools (7zip, git, LLVM)
4848
# These are slower downloads/extractions but don't affect build validation
4949
# ==============================================================================
50-
ADD https://www.7-zip.org/a/7z${ZIP_VERSION}-x64.exe C:/TEMP/7zsetup.exe
50+
ADD https://www.7-zip.org/a/7z${7ZIP_VERSION}-x64.exe C:/TEMP/7zsetup.exe
5151
RUN C:/TEMP/7zsetup.exe /S /D=C:\buildtools\7z `
5252
&& del /q C:\TEMP\7zsetup.exe
5353

@@ -57,7 +57,7 @@ ADD https://github.com/git-for-windows/git/releases/download/v${GIT_VERSION}.win
5757
RUN C:\buildtools\7z\7z.exe x C:/TEMP/git-install.exe -ogit `
5858
&& del /q C:\TEMP\git-install.exe
5959

60-
ADD https://github.com/ghaith/llvm-package-windows/releases/download/v${LLVM_VER}/LLVM-${LLVM_VER}-win64.7z C:/TEMP/llvm.7z
60+
ADD https://github.com/ghaith/llvm-package-windows/releases/download/v${LLVM_VERSION}/LLVM-${LLVM_VERSION}-win64.7z C:/TEMP/llvm.7z
6161
RUN C:\buildtools\7z\7z.exe x C:/TEMP/llvm.7z -ollvm `
6262
&& del /q C:\TEMP\llvm.7z
6363

0 commit comments

Comments
 (0)