Windows-build-CI #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Windows-build-CI | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'The branch to build' | |
required: true | |
default: '3.9' | |
tag_short_version: | |
description: 'The short version of cpython upstream, eg: use 3.9.0 instead of v3.9.0' | |
required: true | |
default: '3.9.0' | |
jobs: | |
build: | |
env: | |
APP_NAME: windows-python-installer | |
runs-on: windows-latest | |
steps: | |
- name: Checkout repository and submodules | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
ref: ${{ github.event.inputs.branch }} | |
- name: 'Checkout and push specified tag version of cpython' | |
run: | | |
git status | |
git config --global pull.rebase false | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
cd cpython | |
git remote -v | |
git fetch --all --tags | |
git checkout tags/v${{ github.event.inputs.tag_short_version }} | |
git status | |
cd .. | |
git add cpython | |
git commit -m "update python to ${{ github.event.inputs.tag_short_version }}" | |
git tag ${{ github.event.inputs.tag_short_version }} | |
git push | |
git push --tag | |
# - name: Install HTML Help Workshop as hhc.exe is need when build chm | |
# run: | | |
# rem unzip resources/html_help_workshop.zip | |
# resources\htmlhelp.exe /T:%cd%\html_help_workshop /C /Q | |
# echo %cd%\html_help_workshop>> %GITHUB_PATH% | |
# shell: cmd | |
# | |
# - name: Testing ${{ github.event.inputs.tag_short_version }}... | |
# run: | | |
# echo %PATH% | |
# where hh hhc | |
# echo GITHUB_REF_NAME: %GITHUB_REF_NAME% | |
# echo github.event.inputs.tag_short_version: ${{ github.event.inputs.tag_short_version }} | |
# shell: cmd | |
# | |
# - name: Check environment in cmd shell | |
# continue-on-error: true | |
# run: | | |
# echo EXTERNALS_DIR: %EXTERNALS_DIR% | |
# tree %EXTERNALS_DIR% | |
# where python | |
# where py | |
# py --list | |
# py -m pip install -v -U blurb | |
# echo ret_code: %ERRORLEVEL% | |
# echo PATH: %PATH% | |
# echo PYTHON: %PYTHON% | |
# rem set HOST_PYTHON=C:\hostedtoolcache\windows\Python\3.9.13\x64\python.exe | |
# call PCbuild\find_python.bat | |
# echo PYTHON: %PYTHON% | |
# echo _Py_Python_Source: %_Py_Python_Source% | |
# working-directory: cpython | |
# shell: cmd | |
# - uses: actions/setup-python@v4 | |
# with: | |
# python-version: '3.9' | |
# - name: Download source code of dependencies (OpenSSL, Tk, etc.) | |
# run: | | |
# call PCbuild/get_externals.bat | |
# call Tools/msi/get_externals.bat | |
# working-directory: cpython | |
# shell: cmd | |
- name: Apply patches ... | |
run: | | |
git apply ../patches/layout.html.patch | |
git apply ../patches/pythonba.vcxproj.patch | |
git apply ../patches/PythonBootstrapperApplication.cpp.patch | |
git apply ../patches/exe_files.wxs.patch | |
git apply ../patches/exe.wixproj.patch | |
git apply ../patches/pyproject.props.patch | |
git apply ../patches/find_python.bat.patch | |
git status | |
git diff | |
working-directory: cpython | |
- name: Copy api-ms-win-core-path-l1-1-0.dll to cpython/PCbuild/{win32,amd64}/ | |
run: | | |
unzip resources/api-ms-win-core-path-blender-0.3.1.zip | |
mkdir -p cpython/PCbuild/{win32,amd64} | |
cp api-ms-win-core-path-blender/x86/api-ms-win-core-path-l1-1-0.dll cpython/PCbuild/win32/ | |
cp api-ms-win-core-path-blender/x64/api-ms-win-core-path-l1-1-0.dll cpython/PCbuild/amd64/ | |
shell: bash | |
- name: Install Microsoft.VisualStudio.Component.VC.140 | |
run: | | |
# Try to fix: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(456,5): error MSB8020: The build tools for Visual Studio 2015 (Platform Toolset = 'v140') cannot be found. To build using the v140 build tools, please install Visual Studio 2015 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [D:\a\windows-python-installer\windows-python-installer\cpython\Tools\msi\bundle\bootstrap\pythonba.vcxproj] | |
# https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022 | |
# https://learn.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2022#use-winget-to-install-or-modify-visual-studio | |
# https://github.com/MicrosoftDocs/visualstudio-docs/blob/main/docs/install/use-command-line-parameters-to-install-visual-studio.md | |
winget install --id Microsoft.VisualStudio.2022.Enterprise --override "--quiet --add Microsoft.VisualStudio.Component.VC.140" | |
- name: Building ... | |
run: | | |
rem -b -> Incrementally build Python rather than rebuilding | |
rem -D -> Do not build documentation | |
rem --skip-pgo -> Build x64 installers without using PGO | |
rem documentation is shared by all platforms, so we need to build it only once | |
rem set PYTHON=py -3.9 | |
rem which python | |
rem python -V | |
rem %PYTHON% -V | |
call Tools\msi\buildrelease.bat -x86 -b | |
call Tools\msi\buildrelease.bat -x64 -b -D | |
working-directory: cpython | |
shell: cmd | |
- name: Checking files ... | |
run: | | |
ls -l Doc/build/htmlhelp/ PCbuild/win32/en-us/ PCbuild/amd64/en-us/ | |
working-directory: cpython | |
shell: bash | |
- uses: xresloader/upload-to-github-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.event.inputs.tag_short_version }} | |
file: |- | |
cpython/Doc/build/htmlhelp/python*.chm; | |
cpython/PCbuild/win32/en-us/python-${{ github.event.inputs.tag_short_version }}-embed-win32.zip; | |
cpython/PCbuild/win32/en-us/python-${{ github.event.inputs.tag_short_version }}.exe; | |
cpython/PCbuild/amd64/en-us/python-${{ github.event.inputs.tag_short_version }}-embed-amd64.zip; | |
cpython/PCbuild/amd64/en-us/python-${{ github.event.inputs.tag_short_version }}-amd64.exe | |
tags: true | |
draft: false | |
overwrite: true |