-
-
Notifications
You must be signed in to change notification settings - Fork 30
179 lines (145 loc) · 6.19 KB
/
build-windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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: Read version from file
id: read_version
run: |
$version = Get-Content -Path ./version -TotalCount 2 | Select-Object -Last 1
echo "::set-output name=version::$version"
- 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 | Node.js
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup | Run Semantic Release
run: npm install --save-dev semantic-release @semantic-release/github @semantic-release/exec && npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}