Skip to content

Commit a1471eb

Browse files
committed
Update build.yml
1 parent 3c998b6 commit a1471eb

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,66 @@ jobs:
7272
path: build/_deps
7373
key: gtest-v1.14.0-${{ matrix.cmake_platform }}
7474

75+
- name: Resolve latest Far tag
76+
id: far_tag
77+
run: |
78+
$headers = @{
79+
'User-Agent' = 'PythonFar-CI'
80+
'Authorization' = "Bearer ${{ secrets.GITHUB_TOKEN }}"
81+
}
82+
$tag = (Invoke-RestMethod -Uri 'https://api.github.com/repos/FarGroup/FarManager/releases?per_page=1' -Headers $headers | Select-Object -First 1).tag_name
83+
$safe = $tag -replace '[/\\]', '-'
84+
Write-Host "Latest Far tag: $tag (safe: $safe)"
85+
"tag=$tag" >> $env:GITHUB_OUTPUT
86+
"safe=$safe" >> $env:GITHUB_OUTPUT
87+
shell: pwsh
88+
89+
- name: Cache Far extract (plugin.hpp)
90+
uses: actions/cache@v4
91+
with:
92+
path: build/far_hpp
93+
key: far-plugin-hpp-${{ steps.far_tag.outputs.safe }}
94+
95+
- name: Extract Far plugin.hpp
96+
run: |
97+
$tag = '${{ steps.far_tag.outputs.tag }}'
98+
$safeTag = '${{ steps.far_tag.outputs.safe }}'
99+
$extractDir = "build\far_hpp"
100+
$headerPath = "$extractDir\PluginSDK\Headers.c\plugin.hpp"
101+
102+
if (Test-Path $headerPath) {
103+
Write-Host "Using cached plugin.hpp from $tag"
104+
Copy-Item $headerPath "include\plugin.hpp" -Force
105+
exit 0
106+
}
107+
108+
$archInFilename = switch ('${{ matrix.arch }}') {
109+
"arm64" { "ARM64" }
110+
default { '${{ matrix.arch }}' }
111+
}
112+
$headers = @{
113+
'User-Agent' = 'PythonFar-CI'
114+
'Authorization' = "Bearer ${{ secrets.GITHUB_TOKEN }}"
115+
}
116+
$asset = (Invoke-RestMethod -Uri "https://api.github.com/repos/FarGroup/FarManager/releases/tags/$([Uri]::EscapeDataString($tag))" -Headers $headers).assets |
117+
Where-Object { $_.name -match "^Far[._](?:[^._]*[._])*$archInFilename[._].*\.7z$" -and $_.name -notlike "*.pdb.7z" } |
118+
Select-Object -First 1
119+
if (-not $asset) { Write-Host "No asset for $archInFilename in $tag, keeping existing include/plugin.hpp"; exit 0 }
120+
121+
New-Item -ItemType Directory -Force -Path $extractDir | Out-Null
122+
$archive = "$env:TEMP\far_archive.7z"
123+
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $archive -Headers $headers -UseBasicParsing
124+
7z x $archive "-o$extractDir" "-aoa" "PluginSDK\Headers.c\plugin.hpp" | Out-Null
125+
Remove-Item $archive -Force
126+
127+
if (Test-Path $headerPath) {
128+
Copy-Item $headerPath "include\plugin.hpp" -Force
129+
Write-Host "Copied plugin.hpp from $tag"
130+
} else {
131+
Write-Host "plugin.hpp not found in archive, keeping existing include/plugin.hpp"
132+
}
133+
shell: pwsh
134+
75135
- name: Configure CMake
76136
run: |
77137
cd build

0 commit comments

Comments
 (0)