Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 164 additions & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: Update VS Build Tools Versions

on:
schedule:
- cron: '0 6 * * *'
workflow_dispatch:

jobs:
update-versions:
runs-on: windows-latest
permissions:
contents: write
issues: write

steps:
- name: Checkout default branch (for repo access)
uses: actions/checkout@v4

- name: Setup cache branch
shell: pwsh
run: |
git fetch origin cache 2>$null

$exists = git ls-remote --exit-code origin cache 2>$null
if ($LASTEXITCODE -eq 0) {
git checkout cache
} else {
Write-Host 'Cache branch does not exist, creating orphan...'
git checkout --orphan cache
git rm -rf . 2>$null
git clean -fd 2>$null
New-Item -ItemType File -Path versions.txt -Force | Out-Null
git add versions.txt
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m 'chore: init cache branch'
git push origin cache
}

- name: Fetch Visual Studio Build Tools packages from WinGet
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'

$oldVersions = @()
if (Test-Path versions.txt) {
$oldVersions = Get-Content versions.txt | Where-Object { $_.Trim() -ne '' }
}

$output = winget search --source winget --id Microsoft.VisualStudio --accept-source-agreements
$packages = @{}

foreach ($line in $output) {
if ($line -match '(Microsoft\.VisualStudio\.BuildTools)\s+([^\s]+)') {
$packages['current'] = "current`tMicrosoft.VisualStudio.BuildTools`t$($Matches[2])"
}

if ($line -match '(Microsoft\.VisualStudio\.(\d{4})\.BuildTools)\s+([^\s]+)') {
$packages[$Matches[2]] = "$($Matches[2])`t$($Matches[1])`t$($Matches[3])"
}
}

$known = @(
"current`tMicrosoft.VisualStudio.BuildTools`t",
"2026`tMicrosoft.VisualStudio.BuildTools`t",
"2022`tMicrosoft.VisualStudio.2022.BuildTools`t",
"2019`tMicrosoft.VisualStudio.2019.BuildTools`t",
"2017`tMicrosoft.VisualStudio.2017.BuildTools`t"
)

foreach ($line in $known) {
$version = $line.Split("`t")[0]
if (-not $packages.ContainsKey($version)) {
$packages[$version] = $line
}
}

$versions = @('current') + (
$packages.Keys |
Where-Object { $_ -match '^\d{4}$' } |
Sort-Object {[int]$_} -Descending
)

$lines = foreach ($version in $versions) { $packages[$version] }
Set-Content -Path versions.txt -Value $lines -Encoding utf8

$oldSet = @{}
foreach ($line in $oldVersions) {
$parts = $line.Split("`t")
if ($parts.Count -gt 0 -and $parts[0] -match '^\d{4}$') {
$oldSet[$parts[0]] = $true
}
}

$newVersions = @()
if ($oldVersions.Count -gt 0) {
foreach ($version in $versions) {
if ($version -match '^\d{4}$' -and -not $oldSet.ContainsKey($version)) {
$newVersions += $version
}
}
}

Set-Content -Path new-vsbuild-versions.txt -Value $newVersions -Encoding utf8
Write-Host "Cached $($lines.Count) Visual Studio Build Tools release lines."

- name: Commit to cache branch if changed
shell: pwsh
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git add versions.txt

git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
Write-Host 'No changes, skipping commit.'
} else {
git commit -m 'chore: bump vsbuild versions cache'
git push origin cache
}

- name: Open package maintenance issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh
run: |
if (-not (Test-Path new-vsbuild-versions.txt)) {
Write-Host 'No new Visual Studio Build Tools versions detected.'
exit 0
}

$versions = Get-Content new-vsbuild-versions.txt | Where-Object { $_.Trim() -ne '' }
if ($versions.Count -eq 0) {
Write-Host 'No new Visual Studio Build Tools versions detected.'
exit 0
}

foreach ($version in $versions) {
$title = "Review Visual Studio Build Tools $version installer profile"
$existing = gh issue list --state open --search "$title in:title" --json title | ConvertFrom-Json | Where-Object { $_.title -eq $title }
if ($existing) {
Write-Host "Issue already exists: $title"
continue
}

$body = @"
The Visual Studio Build Tools versions cache detected a new release line: $version.

Please review whether the fixed install profile in ``lib/windows_vsbuild.lua`` still matches the supported MSVC Build Tools setup.

Focus areas:
- WinGet package ID
- Visual Studio Installer profile behavior
- ``--installPath`` support
- generated helper commands

This issue was opened automatically by the versions cache workflow.
"@

$bodyPath = New-TemporaryFile
Set-Content -Path $bodyPath -Value $body -Encoding utf8
gh issue create --title $title --body-file $bodyPath
Remove-Item $bodyPath -Force
}
72 changes: 72 additions & 0 deletions .github/workflows/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Update latest tag

on:
release:
types: [published]
workflow_dispatch:

permissions:
contents: write

jobs:
update-latest-tag:
runs-on: ubuntu-latest

steps:
- name: Checkout repository with full history
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch --tags --force

- name: Resolve latest release tag from GitHub API
id: latest_release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail

TAG_NAME="$(
gh api \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/releases/latest \
--jq '.tag_name'
)"

if [ -z "${TAG_NAME:-}" ] || [ "${TAG_NAME}" = "null" ]; then
echo "Failed to resolve latest release tag."
exit 1
fi

if ! git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
echo "Latest release tag '$TAG_NAME' does not exist in git refs."
exit 1
fi

TARGET_SHA="$(git rev-list -n 1 "$TAG_NAME")"

echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
echo "target_sha=$TARGET_SHA" >> "$GITHUB_OUTPUT"

echo "Latest release tag: $TAG_NAME"
echo "Target SHA: $TARGET_SHA"

- name: Move latest tag to latest release
shell: bash
run: |
set -euo pipefail

TARGET_TAG="${{ steps.latest_release.outputs.tag_name }}"
TARGET_SHA="${{ steps.latest_release.outputs.target_sha }}"

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

# Create/update lightweight tag so tools can resolve it as a normal commit ref
git tag -f latest "$TARGET_SHA"
git push origin refs/tags/latest --force

echo "Updated latest -> $TARGET_TAG ($TARGET_SHA)"
Loading
Loading