Skip to content

Commit c0b2e66

Browse files
Merge pull request #25 from auto-yui-patch/multi-os-arch-support
Multi-OS-Arch Support (Linux & Windows)
2 parents 1be5fd0 + 63c2ee1 commit c0b2e66

File tree

2 files changed

+388
-65
lines changed

2 files changed

+388
-65
lines changed

.github/workflows/cp_dispatch.yml

Lines changed: 197 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ on:
77
description: 'The Version You Want to Patch'
88
required: true
99
default: '6.0.0'
10+
os-and-arch:
11+
description: 'Operating System And Architecture'
12+
required: true
13+
type: choice
14+
options:
15+
- Windows (x86_64)
16+
- Linux (x86_64)
1017

1118
env:
19+
OS_ARCH: ${{ github.event.inputs.os-and-arch }}
1220
VERSION_TO_PATCH: ${{ github.event.inputs.version_to_patch }}
1321

14-
jobs:
22+
jobs:
1523

1624
validate-version:
1725
runs-on: windows-latest
@@ -65,21 +73,73 @@ jobs:
6573
}
6674
6775
echo "is_valid=$isValid" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
68-
69-
download-Yui-patch:
76+
77+
init_os_arch:
7078
runs-on: windows-latest
79+
outputs:
80+
library_extension: ${{ steps.set_library_extension.outputs.library_extension }}
81+
arch_code: ${{ steps.set_arch.outputs.arch_code }}
82+
83+
steps:
84+
- name: Set Library Extension (dll / so / dylib)
85+
id: set_library_extension
86+
shell: pwsh
87+
run: |
88+
$extension = 'not-selected'
89+
90+
if ($env:OS_ARCH -eq 'Windows (x86_64)') {
91+
$extension = 'dll'
92+
} elseif ($env:OS_ARCH -eq 'Linux (x86_64)') {
93+
$extension = 'so'
94+
} elseif ($env:OS_ARCH -eq 'Mac (arm64)' -or $env:OS_ARCH -eq 'Mac (arm64e)' -or $env:OS_ARCH -eq 'Mac (x86_64)') {
95+
$extension = 'dylib'
96+
} else {
97+
throw "Unsupported OS architecture: $env:OS_ARCH"
98+
}
99+
100+
"library_extension=$extension" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
71101

72-
needs: validate-version
102+
- name: Set Library Extension (dll / so / dylib)
103+
id: set_arch
104+
shell: pwsh
105+
run: |
106+
$arch = 'not-selected'
107+
108+
if ($env:OS_ARCH -eq 'Windows (x86_64)') {
109+
$arch = 'win32-x86_64'
110+
} elseif ($env:OS_ARCH -eq 'Linux (x86_64)') {
111+
$arch = 'linux-x86_64'
112+
} elseif ($env:OS_ARCH -eq 'Mac (arm64)') {
113+
$arch = 'mac-arm64'
114+
} elseif ($env:OS_ARCH -eq 'Mac (arm64e)') {
115+
$arch = 'mac-arm64e'
116+
} elseif ($env:OS_ARCH -eq 'Mac (x86_64)') {
117+
$arch = 'mac-x86_64'
118+
} else {
119+
throw "Unsupported OS architecture: $env:OS_ARCH"
120+
}
121+
122+
"arch_code=$arch" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
123+
124+
download-Yui-patch:
125+
runs-on: windows-latest
126+
needs:
127+
- validate-version
128+
- init_os_arch
73129

74130
if: ${{ needs.validate-version.outputs.is_valid }} == 'true'
75-
131+
132+
env:
133+
LIBRARY_EXTENSION: ${{ needs.init_os_arch.outputs.library_extension }}
134+
ARCH_CODE: ${{ needs.init_os_arch.outputs.arch_code }}
135+
76136
outputs:
77137
is-compatible-cont: ${{ steps.is-compatible-cont.outputs.is-compatible-cont }}
78138
Yui-fiddler-name: ${{ steps.Yui-fiddler-name.outputs.Yui-fiddler-name }}
79139

80140
steps:
81-
- name: Compare Patching Version Compatible with 5.17.0
82-
id: version_check
141+
- name: Compare VERSION_TO_PATCH with 5.17.0
142+
id: version_to_patch_check
83143
run: |
84144
$patchingVersion = $env:VERSION_TO_PATCH
85145
$compareVersion = "5.17.0"
@@ -100,16 +160,20 @@ jobs:
100160
id: is-compatible-cont
101161
run: echo "is-compatible-cont=${{ env.IS_COMPATIBLE_CONT }}" | Out-File -Append -FilePath $env:GITHUB_OUTPUT
102162

103-
- name: Set Yui name
163+
- name: Set Yui name
104164
run: echo "YUI_NAME=yui" | Out-File -Append -FilePath $env:GITHUB_ENV
105165

106166
- name: Set Yui fiddler name (>= 5.17.0)
107167
if: env.IS_COMPATIBLE_CONT == 'true'
108-
run: echo "Yui_FIDDLER_NAME=fiddler" | Out-File -Append -FilePath $env:GITHUB_ENV
168+
run: |
169+
echo "Yui_FIDDLER_NAME=fiddler.$env:LIBRARY_EXTENSION" | Out-File -Append -FilePath $env:GITHUB_ENV
170+
echo "Yui_FIDDLER_NAME_NO_EXTENSION=fiddler" | Out-File -Append -FilePath $env:GITHUB_ENV
109171
110-
- name: Set Yui fiddler name (< 5.17.0)
111-
if: env.IS_COMPATIBLE_CONT == 'false'
112-
run: echo "Yui_FIDDLER_NAME=libfiddler" | Out-File -Append -FilePath $env:GITHUB_ENV
172+
- name: Set Yui fiddler name (< 5.17.0 or on linux)
173+
if: env.IS_COMPATIBLE_CONT == 'false' || env.OS_ARCH == 'Linux (x86_64)'
174+
run: |
175+
echo "Yui_FIDDLER_NAME=libfiddler.$env:LIBRARY_EXTENSION" | Out-File -Append -FilePath $env:GITHUB_ENV
176+
echo "Yui_FIDDLER_NAME_NO_EXTENSION=libfiddler" | Out-File -Append -FilePath $env:GITHUB_ENV
113177
114178
- name: Set Yui_FIDDLER_NAME as Output
115179
id: Yui-fiddler-name
@@ -127,16 +191,18 @@ jobs:
127191

128192
- name: Download Yui Patch
129193
run: |
194+
Write-Host "EXTENSION = $env:LIBRARY_EXTENSION"
195+
Write-Host "ARCH CODE = $env:ARCH_CODE"
130196
try {
131197
# Build the download URLs
132-
$YuiFiddlerUrl = "https://github.com/project-yui/Yui-patch/releases/download/$env:Yui_RELEASE/$env:YUI_NAME-fiddler-win32-x86_64-$env:Yui_RELEASE.dll"
198+
$YuiFiddlerUrl = "https://github.com/project-yui/Yui-patch/releases/download/$env:Yui_RELEASE/$env:YUI_NAME-fiddler-$env:ARCH_CODE-$env:Yui_RELEASE.$env:LIBRARY_EXTENSION"
133199
134200
# Print the URLs to ensure they're correct
135201
Write-Host "Downloading files from $env:Yui_RELEASE"
136202
Write-Host "Yui Fiddler URL: $YuiFiddlerUrl"
137203
138204
# Download the files
139-
Invoke-WebRequest -Uri $YuiFiddlerUrl -OutFile "Yui\$env:Yui_FIDDLER_NAME.dll"
205+
Invoke-WebRequest -Uri $YuiFiddlerUrl -OutFile "Yui\$env:Yui_FIDDLER_NAME"
140206
}
141207
catch {
142208
Write-Error "Failed to download the patch files. Error details: $_"
@@ -154,10 +220,8 @@ jobs:
154220
download-msojocs-server:
155221
runs-on: windows-latest
156222

157-
needs: validate-version
158-
159223
if: ${{ needs.validate-version.outputs.is_valid }} == 'true'
160-
224+
161225
steps:
162226
- name: Set up Git
163227
run: |
@@ -185,12 +249,11 @@ jobs:
185249
path: msojocs/
186250
if-no-files-found: error
187251

188-
download-fiddler-everywhere:
252+
download-fiddler-everywhere-windows:
253+
if: ${{ github.event.inputs.os-and-arch == 'Windows (x86_64)' }}
189254
runs-on: windows-latest
190-
191-
needs: validate-version
192-
193-
if: ${{ needs.validate-version.outputs.is_valid }} == 'true'
255+
needs:
256+
- validate-version
194257

195258
steps:
196259
- name: Build URL & Download
@@ -207,23 +270,119 @@ jobs:
207270
Invoke-WebRequest -Uri $downloadUrl -OutFile "FiddlerEverywhereSetup.exe"
208271
209272
} else {
210-
Write-Host "VERSION_TO_PATCH is empty or not set"
273+
Write-Host "PATCHING_VERSION is empty or not set"
211274
exit 1
212275
}
213276
shell: pwsh
214277

215278
- name: Extract exe
216279
run: 7z x "FiddlerEverywhereSetup.exe" -ofe_extracted
217280

218-
- name: Extract app64
219-
run: 7z x "fe_extracted/`$PLUGINSDIR/app-64.7z" -ofe_app64
281+
- name: Extract app
282+
run: 7z x "fe_extracted/`$PLUGINSDIR/app-64.7z" -ofe_app
283+
shell: pwsh
284+
285+
- name: Upload Fiddler Everywhere Extracted folder as an artifact
286+
uses: actions/upload-artifact@v4
287+
with:
288+
name: fe_app
289+
path: fe_app/
290+
if-no-files-found: error
291+
292+
download-fiddler-everywhere-linux:
293+
if: ${{ github.event.inputs.os-and-arch == 'Linux (x86_64)' }}
294+
runs-on: ubuntu-latest
295+
needs:
296+
- validate-version
297+
298+
steps:
299+
- name: Build URL & Download
300+
run: |
301+
# Retrieve the version to patch from the previous step
302+
$patchingVersion = $env:VERSION_TO_PATCH
303+
304+
# Check if the patchingVersion version is available
305+
if (-not [string]::IsNullOrEmpty($patchingVersion)) {
306+
$downloadUrl = "https://downloads.getfiddler.com/linux/fiddler-everywhere-$patchingVersion.AppImage"
307+
308+
Write-Host "Download URL: $downloadUrl"
309+
310+
Invoke-WebRequest -Uri $downloadUrl -OutFile "FiddlerEverywhereSetup.AppImage"
311+
312+
} else {
313+
Write-Host "VERSION_TO_PATCH is empty or not set"
314+
exit 1
315+
}
316+
shell: pwsh
317+
318+
- name: Extract AppImage
319+
run: |
320+
chmod +x ./FiddlerEverywhereSetup.AppImage
321+
./FiddlerEverywhereSetup.AppImage --appimage-extract
322+
323+
- name: Rename squashfs-root to fe_app
324+
run: mv squashfs-root fe_app
325+
326+
- name: Upload Fiddler Everywhere Extracted folder as an artifact
327+
uses: actions/upload-artifact@v4
328+
with:
329+
name: fe_app
330+
path: fe_app/
331+
if-no-files-found: error
332+
333+
download-fiddler-everywhere-mac:
334+
if: ${{ github.event.inputs.os-and-arch == 'Mac (x86_64)' || github.event.inputs.os-and-arch == 'Mac (arm64)' || github.event.inputs.os-and-arch == 'Mac (arm64e)' }}
335+
runs-on: mac-latest
336+
needs:
337+
- validate-version
338+
339+
env:
340+
ARCH_CODE: ${{ github.event.inputs.arch_code }}
341+
342+
steps:
343+
- name: Build URL & Download
344+
run: |
345+
# Retrieve the version_to_patch version from the previous step
346+
$patchingVersion = $env:VERSION_TO_PATCH
347+
348+
# Check if the version_to_patch version is available
349+
if (-not [string]::IsNullOrEmpty($patchingVersion)) {
350+
$downloadUrl = "null"
351+
352+
if ($env:ARCH_CODE -eq "x86_64") {
353+
$downloadUrl = "https://downloads.getfiddler.com/mac/Fiddler%20Everywhere%20$patchingVersion.dmg"
354+
} elseif ($env:ARCH_CODE -eq "arm64") {
355+
$downloadUrl = "https://downloads.getfiddler.com/mac-arm64/Fiddler%20Everywhere%20$patchingVersion.dmg"
356+
} elseif ($env:ARCH_CODE -eq "arm64e") {
357+
//Don't know
358+
} else {
359+
throw "Unsupported OS architecture: $env:ARCH_CODE"
360+
}
361+
362+
Write-Host "Download URL: $downloadUrl"
363+
364+
Invoke-WebRequest -Uri $downloadUrl -OutFile "FiddlerEverywhereSetup.dmg"
365+
366+
} else {
367+
Write-Host "VERSION_TO_PATCH is empty or not set"
368+
exit 1
369+
}
370+
shell: pwsh
371+
372+
- name: Extract AppImage
373+
run: |
374+
hdiutil attach FiddlerEverywhere.dmg
375+
cp -R /Volumes/FiddlerEverywhere/* ./fe_app/
376+
377+
- name: List fe_app
220378
shell: pwsh
379+
run: Get-ChildItem -Recurse
221380

222381
- name: Upload Fiddler Everywhere Extracted folder as an artifact
223382
uses: actions/upload-artifact@v4
224383
with:
225-
name: fe_app64
226-
path: fe_app64/
384+
name: fe_app
385+
path: fe_app/
227386
if-no-files-found: error
228387

229388
patch_fe:
@@ -232,7 +391,11 @@ jobs:
232391
needs:
233392
- download-Yui-patch
234393
- download-msojocs-server
235-
- download-fiddler-everywhere
394+
- validate-version
395+
- download-fiddler-everywhere-windows
396+
- download-fiddler-everywhere-linux
397+
- download-fiddler-everywhere-mac
398+
if: always()
236399

237400
outputs:
238401
patched-fe-name: ${{ steps.rename-fe.outputs.patched-fe-name }}
@@ -253,23 +416,23 @@ jobs:
253416
- name: Download FE
254417
uses: actions/download-artifact@v4
255418
with:
256-
name: fe_app64
257-
path: fe_app64
419+
name: fe_app
420+
path: fe_app
258421

259422
- name: List the contents of the downloaded artifacts
260423
run: |
261424
Get-ChildItem -Recurse Yui-patch
262425
Get-ChildItem -Recurse msojocs-patch
263-
Get-ChildItem -Recurse fe_app64
426+
Get-ChildItem -Recurse fe_app
264427
shell: pwsh
265428

266429
- name: Rename main FE folder
267-
run: Rename-Item -Path "fe_app64" -NewName "FE"
430+
run: Rename-Item -Path "fe_app" -NewName "FE"
268431

269432
- name: Patch fiddler.dll / libfiddler.dll
270433
run: |
271-
$original_fiddler = "FE/${{ needs.download-Yui-patch.outputs.Yui-fiddler-name }}.dll"
272-
$Yui_fiddler = "Yui-patch/${{ needs.download-Yui-patch.outputs.Yui-fiddler-name }}.dll"
434+
$original_fiddler = "FE/${{ needs.download-Yui-patch.outputs.Yui-fiddler-name }}"
435+
$Yui_fiddler = "Yui-patch/${{ needs.download-Yui-patch.outputs.Yui-fiddler-name }}"
273436
274437
if ((Test-Path $original_fiddler) -and (Test-Path $Yui_fiddler)) {
275438
Copy-Item -Path $Yui_fiddler -Destination $original_fiddler -Force

0 commit comments

Comments
 (0)