-
Notifications
You must be signed in to change notification settings - Fork 18
167 lines (146 loc) · 6.17 KB
/
update_sdk.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Update SDK
on:
schedule:
- cron: "0 2 * * *" # Runs daily at 02:00 UTC
workflow_dispatch:
jobs:
update-sdk:
name: "Update ${{ matrix.sdk.commit_message }}"
runs-on: windows-latest
permissions:
contents: write
pull-requests: write
strategy:
matrix:
sdk:
- name: "Microsoft.WindowsAppSDK"
commit_message: "Windows App SDK"
allow_prerelease: false
script_file_name: "scripts\\get_appsdk.ps1"
additional_script: "scripts\\update_appsdk.py"
json_file_name: "WindowsAppSDK.json"
- name: "Microsoft.Web.WebView2"
commit_message: "Microsoft.Web.WebView2"
allow_prerelease: false
script_file_name: "scripts\\get_webview2.ps1"
additional_script: "scripts\\update_webview2.py"
json_file_name: "Microsoft.Web.WebView2.Core.json"
- name: "Microsoft.Windows.SDK.Win32Metadata"
commit_message: "Win32Metadata"
allow_prerelease: true
script_file_name: "scripts\\get_win32.ps1"
json_file_name: "Windows.Win32.json"
- name: "Microsoft.Windows.SDK.Contracts"
commit_message: "Windows SDK"
allow_prerelease: false
script_file_name: "scripts\\get_winrt.ps1"
json_file_name: "WindowsSDK.json"
steps:
- name: git config
run: git config --global core.autocrlf false
- name: Checkout win32more code
uses: actions/checkout@v4
with:
path: win32more
- name: Find latest version
run: |
$packageName = "${{ matrix.sdk.name }}".ToLower()
$uri = "https://api.nuget.org/v3-flatcontainer/$packageName/index.json"
$response = Invoke-RestMethod -Uri $uri
if ($${{ matrix.sdk.allow_prerelease}}) {
$versions = $response.versions
} else {
$versions = $response.versions | Where-Object { $_ -notmatch "-" }
}
if ($versions.Count -eq 0) {
throw "No versions found."
}
$latestVersion = $versions[-1]
$latestVersion = $latestVersion -replace '-preview$', ''
echo "latestVersion=$latestVersion" >> $env:GITHUB_ENV
- name: Verify if there is an update
id: is-there-update
run: |
$jsonPath = "win32generator\resources\metadata\versions.json"
$jsonContent = Get-Content -Path $jsonPath -Raw | ConvertFrom-Json
$version = $jsonContent."${{ matrix.sdk.name }}"
if ([System.Version]$env:latestVersion -le [System.Version]$version) {
Write-Output "There isn't any new version of ${{ matrix.sdk.name }}."
echo "isSuccess=false" >> $env:GITHUB_OUTPUT
} else {
echo "isSuccess=true" >> $env:GITHUB_OUTPUT
}
working-directory: win32more
- name: Checkout winmd-printer code
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
uses: actions/checkout@v4
with:
repository: ynkdir/winmd-printer
path: winmd-printer
- name: Setup .NET
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Setup Python
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Setup 7-Zip
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: choco install 7zip --yes
- name: Run ${{ matrix.sdk.script_file_name }}
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: ${{ matrix.sdk.script_file_name }} $env:latestVersion
working-directory: winmd-printer
- name: Compress ${{ matrix.sdk.json_file_name }} with 7-Zip
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: |
Remove-Item win32more\win32generator\resources\metadata\${{ matrix.sdk.json_file_name }}.xz
7z a -txz win32more\win32generator\resources\metadata\${{ matrix.sdk.json_file_name }}.xz winmd-printer\${{ matrix.sdk.json_file_name }}
- name: Run win32generator
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: python -m win32generator
working-directory: win32more
- name: Run additional script if defined
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' && matrix.sdk.additional_script != '' }}
run: python ${{ matrix.sdk.additional_script }} $env:latestVersion
working-directory: win32more
- name: Update versions.json
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: |
$jsonPath = "win32generator\resources\metadata\versions.json"
$jsonContent = Get-Content -Path $jsonPath -Raw | ConvertFrom-Json
$jsonContent."${{ matrix.sdk.name }}" = $env:latestVersion
$updatedJson = $jsonContent | ConvertTo-Json
Set-Content $jsonPath $updatedJson
working-directory: win32more
- name: Commit changes
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Checkout the branch, it if it exist, delete it.
$branchName = "update-${{ matrix.sdk.name }}-$env:latestVersion"
git fetch origin
if (git branch --list $branchName) {
git branch -D $branchName
}
git checkout -b $branchName
git add .
git commit --allow-empty -m "${{ matrix.sdk.commit_message }} $env:latestVersion"
# Force push to overwrite the branch
git push origin HEAD --force
working-directory: win32more
- name: Create Pull Request
if: ${{ steps.is-there-update.outputs.isSuccess == 'true' }}
run: |
gh pr create `
--title "[${{ matrix.sdk.commit_message }}] Update to $env:latestVersion" `
--body "" `
--base ${{ github.event.repository.default_branch }} `
--head update-${{ matrix.sdk.name }}-$env:latestVersion `
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: win32more