Skip to content

Build Millennium

Build Millennium #130

Workflow file for this run

name: Build Millennium (Windows)
on:
workflow_dispatch:
jobs:
build:
permissions:
contents: write
issues: write
pull-requests: write
runs-on: windows-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true # allow fortnite wallhacks
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
strategy:
fail-fast: false
matrix:
include:
- sys: mingw32
env: i686
steps:
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: true
- name: Setup | Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup | Semantic Release
run: npm install --save-dev semantic-release @semantic-release/github @semantic-release/exec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# dry run to get the next version
- name: Bump Version
id: read_version
run: |
$VERSION = npx semantic-release --dry-run | Select-String -Pattern "The next release version is" | ForEach-Object { $_.ToString() -replace '.*The next release version is ([0-9.]+).*', '$1' }
Write-Host "Version: $VERSION"
echo "::set-output name=version::$version"
Set-Content -Path ./version -Value "# current version of millennium`nv$VERSION"
git config user.email "[email protected]"
git config user.name "GitHub Actions"
git add version
git commit -m "chore(release): bump version to v$VERSION"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if release already exists
id: check_release
run: |
# Define the URL of the GitHub API endpoint
$url = "https://api.github.com/repos/SteamClientHomebrew/Millennium/releases/tags/${{ steps.read_version.outputs.version }}"
# Make the HTTP request and retrieve the response
try {
$response = Invoke-WebRequest -Uri $url -Method Get -ErrorAction Stop
$status_code = $response.StatusCode
# Check if the release exists based on the status code
if ($status_code -eq 200) {
Write-Error "Release ${{ steps.read_version.outputs.version }} already exists."
exit 1
}
} catch {
Write-Output "Release ${{ steps.read_version.outputs.version }} not found. Continuing workflow."
}
- name: Set up cache for Python source
uses: actions/cache@v3
id: build-cache
with:
path: |
Python-3.11.8/PCbuild/win32
key: ${{ runner.os }}-python-3.11.8-build
restore-keys: |
${{ runner.os }}-python-3.11.8-build-
- name: (Python) Download 3.11.8 win32 source
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
# download python 3.11.8 source code
curl -o Python-3.11.8.tgz https://www.python.org/ftp/python/3.11.8/Python-3.11.8.tgz
# extract the tarball
tar -xzvf Python-3.11.8.tgz >nul 2>&1
- name: (Python) Stage Python 3.11.8 static build
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cd Python-3.11.8
$vcxprojPath = "PCbuild/pythoncore.vcxproj"
$content = Get-Content $vcxprojPath -Raw # Read the entire content as a single string
$pattern = '</ClCompile>'
$replacement = @"
<RuntimeLibrary Condition="'`$(Configuration)|`$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
<RuntimeLibrary Condition="'`$(Configuration)|`$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
"@
$modifiedContent = $content -replace [regex]::Escape($pattern), $replacement
$modifiedContent | Set-Content $vcxprojPath
shell: pwsh
- name: (Python) Build 3.11.8
if: steps.build-cache.outputs.cache-hit != 'true'
run: |
cd Python-3.11.8
# get python external libs before build
./PCbuild/get_externals.bat
# build python 3.11.8 as win32 and release
msbuild PCBuild/pcbuild.sln /p:Configuration=Release /p:Platform=Win32 /p:RuntimeLibrary=MT
msbuild PCBuild/pcbuild.sln /p:Configuration=Debug /p:Platform=Win32 /p:RuntimeLibrary=MT
# verify python is installed
PCbuild/win32/python.exe --version
- name: Upload Python artifacts
run: |
mkdir D:/a/Millennium/Millennium/build/python
# Move the python311.dll binary to the release directory
copy D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311.dll D:/a/Millennium/Millennium/build/python/python311.dll
copy D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311_d.dll D:/a/Millennium/Millennium/build/python/python311_d.dll
copy D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311.lib D:/a/Millennium/Millennium/build/python/python311.lib
copy D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311_d.lib D:/a/Millennium/Millennium/build/python/python311_d.lib
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: python 3.11.8 build libraries
path: D:/a/Millennium/Millennium/build/python
- name: Install prerequisites
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
install: >-
mingw-w64-${{ matrix.env }}-libgcrypt
mingw-w64-${{ matrix.env }}-gcc
mingw-w64-${{ matrix.env }}-cmake
mingw-w64-${{ matrix.env }}-ninja
- name: (Dependency) Install vcpkg
shell: pwsh
run: |
# bootstrap and install vcpkg
./vendor/vcpkg/bootstrap-vcpkg.bat
./vendor/vcpkg/vcpkg integrate install
- name: (Generator) Configure CMake
shell: msys2 {0}
run: |
ninja --version
cmake --preset=windows-mingw-release -DGITHUB_ACTION_BUILD=ON
- name: Build Millennium
shell: msys2 {0}
run: |
mkdir D:/a/Millennium/Millennium/build/artifacts
# build millennium with msvc; x86; release
cmake --build build --config Release
ls ./build
# Move the python311.dll binary to the release directory
cp D:/a/Millennium/Millennium/Python-3.11.8/PCbuild/win32/python311.dll D:/a/Millennium/Millennium/build/artifacts/python311.dll
cp /d/a/Millennium/Millennium/build/user32.dll D:/a/Millennium/Millennium/build/artifacts
- name: Setup | Run Semantic Release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}