Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0a7980

Browse files
committed
create two smaller actions
(gemini suggestion)
1 parent 2859c80 commit a0a7980

File tree

3 files changed

+101
-49
lines changed

3 files changed

+101
-49
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: 'WinPython Pandoc Setup'
2+
description: 'Downloads and integrates Pandoc into the WinPython structure'
3+
inputs:
4+
pandoc_source:
5+
description: 'Pandoc download URL'
6+
required: true
7+
pandoc_sha256:
8+
description: 'Expected SHA256 for Pandoc'
9+
required: true
10+
build_location:
11+
description: 'The target WinPython folder'
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Download and Integrate Pandoc
18+
shell: pwsh
19+
run: |
20+
$zipPath = "pandoc.zip"
21+
$tempDir = "pandoc_temp"
22+
$targetDir = Join-Path "${{ inputs.build_location }}" "t"
23+
24+
Write-Host "Downloading Pandoc..."
25+
curl.exe -L -o $zipPath "${{ inputs.pandoc_source }}"
26+
27+
$actualHash = (Get-FileHash -Path $zipPath -Algorithm SHA256).Hash.ToLower()
28+
if ($actualHash -ne "${{ inputs.pandoc_sha256 }}".ToLower()) {
29+
Write-Error "Pandoc SHA mismatch!"
30+
exit 1
31+
}
32+
33+
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
34+
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
35+
36+
# Move only the executable (adjusting for the internal folder name in the zip)
37+
Get-ChildItem -Path "$tempDir\pandoc-*\pandoc.exe" | Copy-Item -Destination $targetDir -Force
38+
39+
Remove-Item $tempDir -Recurse -Force
40+
Remove-Item $zipPath -Force
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'WinPython Standalone Setup'
2+
description: 'Downloads, verifies, and extracts Python Build Standalone'
3+
inputs:
4+
python_source:
5+
description: 'URL of the python tar.gz'
6+
required: true
7+
python_sha256:
8+
description: 'Expected SHA256'
9+
required: true
10+
build_location:
11+
description: 'Target directory name'
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Download and Extract python
18+
shell: pwsh
19+
run: |
20+
$archive = "python-3-embed.tar.gz"
21+
Write-Host "Downloading: ${{ inputs.python_source }}"
22+
curl.exe -L -o $archive "${{ inputs.python_source }}"
23+
24+
# Hash Verification
25+
$actualHash = (Get-FileHash -Path $archive -Algorithm SHA256).Hash.ToLower()
26+
if ($actualHash -ne "${{ inputs.python_sha256 }}".ToLower()) {
27+
Write-Error "SHA mismatch: $actualHash"
28+
exit 1
29+
}
30+
31+
# Setup Folders
32+
mkdir "dotpythonpre" -Force
33+
mkdir "dotpython/python" -Force
34+
35+
# Extract
36+
tar -xf $archive -C "dotpythonpre"
37+
38+
# Handle different internal structures (install vs root)
39+
if (Test-Path "dotpythonpre/python/install") {
40+
Move-Item -Path "dotpythonpre/python/install/*" -Destination "dotpython/python" -Force
41+
} else {
42+
Move-Item -Path "dotpythonpre/python/*" -Destination "dotpython/python" -Force
43+
}
44+
45+
# Move to final location
46+
mkdir "${{ inputs.build_location }}" -Force
47+
Move-Item -Path "dotpython/*" -Destination "${{ inputs.build_location }}" -Force
48+
49+
# Cleanup
50+
Remove-Item "dotpythonpre" -Recurse -Force
51+
Remove-Item $archive -Force

.github/workflows/github_workflows_build-2026_01.yml

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,11 @@ jobs:
162162
163163
- name: Download, verify and extract python standalone
164164
if: env.WINPYREQUIREMENTS != ''
165-
shell: pwsh
166-
run: |
167-
Write-Output "Downloading, hash-checking, and extracting $env:python_source"
168-
curl.exe -L -o "python-3-embed.tar.gz" $env:python_source
169-
170-
$expectedHash = $env:python_sha256
171-
$actualHash = (Get-FileHash -Path "python-3-embed.tar.gz" -Algorithm SHA256).Hash.ToLower()
172-
if ($actualHash -ne $expectedHash.ToLower()) {
173-
Write-Error "SHA mismatch: Actual $actualHash doesn't match $expectedHash"
174-
exit 1
175-
} else { Write-Output "Python SHA ok" }
176-
177-
mkdir dotpythonpre -Force
178-
mkdir dotpython -Force
179-
mkdir dotpython/python -Force
180-
tar -xf python-3-embed.tar.gz -C dotpythonpre
181-
if (Test-Path dotpythonpre/python/install) {
182-
Move-Item -Path dotpythonpre/python/install/* -Destination dotpython/python -Force
183-
} elseif (Test-Path dotpythonpre/python) {
184-
Move-Item -Path dotpythonpre/python/* -Destination dotpython/python -Force
185-
}
165+
uses: ./.github/actions/python-setup
166+
with:
167+
python_source: ${{ env.python_source }}
168+
python_sha256: ${{ env.python_sha256 }}
169+
build_location: ${{ env.build_location }}
186170

187171
- name: Copy launchers_final files to dotpython
188172
if: env.WINPYREQUIREMENTS != ''
@@ -207,34 +191,11 @@ jobs:
207191
208192
- name: Download, checking hash and integrating pandoc binary
209193
if: env.WINPYREQUIREMENTS != '' && env.PANDOC == '1'
210-
shell: pwsh
211-
run: |
212-
$pandocZipPath = "pandoc.zip"
213-
$tempDir = "pandoc_temp"
214-
$targetDir = Join-Path $env:build_location "t"
215-
Write-Host "Downloading Pandoc from $env:pandoc_source"
216-
curl.exe -L -o $pandocZipPath $env:pandoc_source
217-
218-
$expectedHash = $env:pandoc_sha256.ToLower()
219-
$actualHash = (Get-FileHash -Path $pandocZipPath -Algorithm SHA256).Hash.ToLower()
220-
221-
if ($actualHash -ne $expectedHash) {
222-
Write-Error "Pandoc SHA mismatch: $actualHash vs expected $expectedHash"
223-
exit 1
224-
} else { Write-Output "Pandoc SHA ok" }
225-
226-
Expand-Archive -Path $pandocZipPath -DestinationPath $tempDir -Force
227-
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
228-
229-
Write-Output "Copying pandoc.exe to $targetDir"
230-
Copy-Item -Path (Join-Path $tempDir "pandoc-3.1.9\pandoc.exe") -Destination $targetDir -Force
231-
232-
Write-Output "Showing the content of $targetDir"
233-
Get-ChildItem -Path $targetDir
234-
235-
Write-Output "Cleaning up temporary files..."
236-
Remove-Item -Path $tempDir -Recurse -Force
237-
Remove-Item -Path $pandocZipPath -Force
194+
uses: ./.github/actions/pandoc-setup
195+
with:
196+
pandoc_source: ${{ env.pandoc_source }}
197+
pandoc_sha256: ${{ env.pandoc_sha256 }}
198+
build_location: ${{ env.build_location }}
238199

239200
- name: Upgrade pip and patch launchers
240201
if: env.WINPYREQUIREMENTS != ''

0 commit comments

Comments
 (0)