Skip to content

Commit 8abb19e

Browse files
committed
separate-out publication logic
1 parent d93b297 commit 8abb19e

File tree

2 files changed

+102
-56
lines changed

2 files changed

+102
-56
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: 'WinPython Publish Action'
2+
description: 'Generates metadata, pylock files, compresses artifacts, and calculates hashes'
3+
4+
inputs:
5+
build_location:
6+
required: true
7+
description: 'Path to the build folder'
8+
winpy_flavor:
9+
required: true
10+
winpy_arch:
11+
required: true
12+
winpy_ver:
13+
required: true
14+
winpy_ver2:
15+
required: true
16+
dotwheelhouse:
17+
required: true
18+
winpy_requirements_whl:
19+
required: false
20+
default: ""
21+
format_zip:
22+
required: true
23+
format_7z:
24+
required: true
25+
format_exe:
26+
required: true
27+
28+
runs:
29+
using: "composite"
30+
steps:
31+
- name: Generate Metadata and Pylock
32+
shell: pwsh
33+
run: |
34+
mkdir -Force publish_output
35+
$env:PYTHONIOENCODING="utf-8"
36+
$pythonExe = Join-Path "${{ inputs.build_location }}" "python\python.exe"
37+
38+
# Markdown Metadata
39+
$destfile_md = "publish_output\WinPython${{ inputs.winpy_flavor }}-${{ inputs.winpy_arch }}bit-${{ inputs.winpy_ver2 }}.md"
40+
& $pythonExe -m wppm -md | Out-File -FilePath $destfile_md -Encoding utf8
41+
gc $destfile_md
42+
43+
# Pylock and Requirements
44+
& $pythonExe -m pip freeze | Out-File -FilePath dotpython\freeze.txt
45+
$verClean = "${{ inputs.winpy_ver }}" -replace '\.', '_'
46+
$destfile_pylock = "publish_output\pylock.${{ inputs.winpy_arch }}-$verClean.toml"
47+
& $pythonExe -m pip lock --no-deps --find-links="${{ inputs.dotwheelhouse }}" -r dotpython\freeze.txt -o $destfile_pylock
48+
49+
$outreq = "publish_output\requir.${{ inputs.winpy_arch }}-$verClean.txt"
50+
& $pythonExe -X utf8 -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'$destfile_pylock', r'$outreq')"
51+
52+
# Handle Optional Wheelhouse
53+
if ("${{ inputs.winpy_requirements_whl }}" -ne "") {
54+
$destfile_pylockwheel = "publish_output\pylock.${{ inputs.winpy_arch }}-${verClean}_wheels.toml"
55+
& $pythonExe -m pip lock --no-deps --require-hashes -r "${{ inputs.winpy_requirements_whl }}" -o $destfile_pylockwheel
56+
57+
$outreqwheel = "publish_output\requir.${{ inputs.winpy_arch }}-${verClean}_wheels.txt"
58+
& $pythonExe -X utf8 -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'$destfile_pylockwheel', r'$outreqwheel')"
59+
60+
$whPath = Join-Path "${{ inputs.build_location }}" "wheelhouse"
61+
Copy-Item -Path $outreqwheel -Destination $whPath -Force
62+
Copy-Item -Path $destfile_pylockwheel -Destination $whPath -Force
63+
}
64+
65+
- name: Compress Build
66+
shell: pwsh
67+
run: |
68+
$baseName = "publish_output\WinPython${{ inputs.winpy_arch }}-${{ inputs.winpy_ver }}"
69+
70+
if ("${{ inputs.format_zip }}" -eq "true") {
71+
Compress-Archive -Path "${{ inputs.build_location }}" -DestinationPath "$baseName.zip" -Force
72+
}
73+
if ("${{ inputs.format_7z }}" -eq "true") {
74+
7z a "$baseName.7z" "${{ inputs.build_location }}"
75+
}
76+
if ("${{ inputs.format_exe }}" -eq "true") {
77+
$SFXModulePath = "C:\Program Files\7-Zip\7z.sfx"
78+
7z a -t7z -sfx"$SFXModulePath" "$baseName.exe" "${{ inputs.build_location }}"
79+
}
80+
81+
- name: Generate Hashes
82+
shell: pwsh
83+
run: |
84+
$pythonExe = Join-Path "${{ inputs.build_location }}" "python\python.exe"
85+
$DESTFILE = "./publish_output/hashes.md"
86+
$filesToHash = Get-ChildItem -Path ".\publish_output\*64*.*"
87+
& $pythonExe -c "import sys;from wppm import hash; hash.print_hashes(sys.argv[1:])" @($filesToHash.FullName) | Out-File -FilePath $DESTFILE
88+
gc $DESTFILE
89+

.github/workflows/github_workflows_build-2026_01.yml

Lines changed: 13 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -203,63 +203,20 @@ jobs:
203203
run: |
204204
& "$env:build_location\python\python.exe" -m pip install --no-deps --no-index --trusted-host=None --find-links=$env:dotwheelhouse --require-hashes -r $env:WINPYREQUIREMENTS
205205
206-
- name: Generate Markdown content and pylock file
206+
- name: Generate Assets and Hashes
207207
if: env.WINPYREQUIREMENTS != ''
208-
shell: pwsh
209-
run: |
210-
mkdir publish_output
211-
212-
# Ensure unicode for wppm output
213-
$env:PYTHONIOENCODING="utf-8"
214-
215-
$destfile_md = "publish_output\WinPython$env:WINPYFLAVOR-$($env:WINPYARCH)bit-$env:WINPYVER2.md"
216-
& "$env:build_location\python\python.exe" -m wppm -md | Out-File -FilePath $destfile_md -Encoding utf8
217-
218-
gc $destfile_md
219-
220-
& "$env:build_location\python\python.exe" -m pip freeze | Out-File -FilePath dotpython\freeze.txt
221-
$destfile_pylock = "publish_output\pylock.$env:WINPYARCH-$($env:WINPYVER -replace '\.', '_').toml"
222-
& "$env:build_location\python\python.exe" -m pip lock --no-deps --find-links=$env:dotwheelhouse -r dotpython\freeze.txt -o $destfile_pylock
223-
224-
$outreq = "publish_output\requir.$env:WINPYARCH-$($env:WINPYVER -replace '\.', '_').txt"
225-
& "$env:build_location\python\python.exe" -X utf8 -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'$destfile_pylock', r'$outreq')"
226-
227-
if ($env:WINPYREQUIREMENTSwhl -eq "") {
228-
Write-Output "No additional wheelhouse requirements."
229-
} else {
230-
$destfile_pylockwheel = "publish_output\pylock.$env:WINPYARCH-$($env:WINPYVER -replace '\.', '_')_wheels.toml"
231-
& "$env:build_location\python\python.exe" -m pip lock --no-deps --require-hashes -r $env:WINPYREQUIREMENTSwhl -o $destfile_pylockwheel
232-
233-
$outreqwheel = "publish_output\requir.$env:WINPYARCH-$($env:WINPYVER -replace '\.', '_')_wheels.txt"
234-
& "$env:build_location\python\python.exe" -X utf8 -c "from wppm import wheelhouse as wh; wh.pylock_to_req(r'$destfile_pylockwheel', r'$outreqwheel')"
235-
Copy-Item -Path $outreqwheel -Destination (Join-Path $env:build_location "wheelhouse") -Force
236-
Copy-Item -Path $destfile_pylockwheel -Destination (Join-Path $env:build_location "wheelhouse") -Force
237-
}
238-
239-
- name: compress the result (zip / 7z / self-extracting.exe)
240-
if: env.WINPYREQUIREMENTS != ''
241-
shell: pwsh
242-
run: |
243-
$destfile = "publish_output\WinPython$env:WINPYARCH-$env:WINPYVER.zip"
244-
if ("${{ matrix.flavor.formats['zip'] }}" -eq "true") { Compress-Archive -Path "$env:build_location" -DestinationPath $destfile }
245-
246-
$destfile = "publish_output\WinPython$env:WINPYARCH-$env:WINPYVER.7z"
247-
if ("${{ matrix.flavor.formats['7z'] }}" -eq "true") { 7z a $destfile $env:build_location }
248-
249-
$destfile = "publish_output\WinPython$env:WINPYARCH-$env:WINPYVER.exe"
250-
$SFXModulePath = "C:\Program Files\7-Zip\7z.sfx"
251-
if ("${{ matrix.flavor.formats['exe'] }}" -eq "true") { 7z a -t7z -sfx"$SFXModulePath" $destfile $env:build_location }
252-
253-
- name: generate hashes wppm style
254-
if: env.WINPYREQUIREMENTS != ''
255-
shell: pwsh
256-
run: |
257-
$DESTFILE="./publish_output/hashes.md"
258-
Get-ChildItem -Path ".\publish_output\*.*"
259-
# Get the list of files matching the pattern and pass them as arguments
260-
$filesToHash = Get-ChildItem -Path ".\publish_output\*64*.*"
261-
& "$env:build_location\python\python.exe" -c "import sys;from wppm import hash; hash.print_hashes(sys.argv[1:])" @($filesToHash.FullName) | Out-File -FilePath $DESTFILE
262-
gc $DESTFILE
208+
uses: ./.github/actions/publish-winpython
209+
with:
210+
build_location: ${{ env.build_location }}
211+
winpy_flavor: ${{ env.WINPYFLAVOR }}
212+
winpy_arch: ${{ env.WINPYARCH }}
213+
winpy_ver: ${{ env.WINPYVER }}
214+
winpy_ver2: ${{ env.WINPYVER2 }}
215+
dotwheelhouse: ${{ env.dotwheelhouse }}
216+
winpy_requirements_whl: ${{ env.WINPYREQUIREMENTSwhl }}
217+
format_zip: ${{ matrix.flavor.formats.zip }}
218+
format_7z: ${{ matrix.flavor.formats.7z }}
219+
format_exe: ${{ matrix.flavor.formats.exe }}
263220

264221
- name: Upload artifacts
265222
if: env.WINPYREQUIREMENTS != ''

0 commit comments

Comments
 (0)