-
-
Notifications
You must be signed in to change notification settings - Fork 12
175 lines (148 loc) · 7.1 KB
/
windows-exe-build.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
name: Build Windows Executable
env:
AAA_VERSION: "1.2.3"
on:
workflow_dispatch:
# push:
# branches:
# - main
jobs:
build-windows:
runs-on: windows-latest
outputs:
upload_url_base64: ${{ steps.b64encode_upload_url.outputs.upload_url_base64 }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup MSBuild
uses: microsoft/[email protected] #using Microsoft's setup-msbuild action
- name: Install python packages
run: |
# Create the python-embedded directory if it doesn't exist
$pythonEmbeddedDir = ".\python-embedded"
If (-Not (Test-Path $pythonEmbeddedDir)) {
New-Item -ItemType Directory -Force -Path $pythonEmbeddedDir
}
# Download the embedded Python zip
curl https://www.python.org/ftp/python/3.12.1/python-3.12.1-embed-amd64.zip -o "python.zip"
# Extract the Python zip
Expand-Archive -Path "python.zip" -DestinationPath $pythonEmbeddedDir -Force
# Download pip.pyz
curl https://bootstrap.pypa.io/pip/pip.pyz -o "$pythonEmbeddedDir\pip.pyz"
# Install packages from requirements.txt using the embedded Python and pip.pyz
& "$pythonEmbeddedDir\python.exe" "$pythonEmbeddedDir\pip.pyz" install -r .\requirements.txt --target=".\Lib\site-packages\"
Remove-Item -Recurse -Force .\python-embedded
Move-Item -Path python.zip -Destination AzerothAuctionAssassin-windows\AzerothAuctionAssassin\Resources\python.zip -Force
shell: pwsh
- name: Zip python packages
run: |
Compress-Archive -Path .\Lib -DestinationPath Lib.zip
Move-Item -Path Lib.zip -Destination AzerothAuctionAssassin-windows\AzerothAuctionAssassin\Resources\Lib.zip -Force
Remove-Item -Recurse -Force .\Lib
- name: Zip Project Files
run: |
$DirToCompress = ".\"
$ZipFileResult = "..\app.zip"
$DirsToExclude = @("AzerothAuctionAssassin-windows", ".git", ".github", "__pycache__")
$FilesToExclude = @(".gitignore")
# Get all directories that are not in the exclude list and compress them
Get-ChildItem -Path $DirToCompress -Directory | Where-Object { $_.Name -notin $DirsToExclude } | Compress-Archive -DestinationPath $ZipFileResult -Update
# Get all Files that are not in the exclude list and compress them
Get-ChildItem -Path $DirToCompress -File | Where-Object { $_.Name -notin $FilesToExclude } | Compress-Archive -DestinationPath $ZipFileResult -Update
Move-Item -Path ..\app.zip -Destination AzerothAuctionAssassin-windows\AzerothAuctionAssassin\Resources\app.zip -Force
shell: pwsh
- name: update version number
run: |
echo $env:AAA_VERSION > AzerothAuctionAssassin-windows\AzerothAuctionAssassin\Resources\appVersion.txt
shell: pwsh
- name: Build EXE
run: |
msbuild AzerothAuctionAssassin-windows\AzerothAuctionAssassin.sln -restore -t:Publish /p:Configuration=Release /p:PublishProfile=".\AzerothAuctionAssassin\Properties\PublishProfiles\FolderProfile.pubxml"
- name: Decode Certificate
run: |
$cert_content = '${{ secrets.CERT_BASE64 }}'
$cert_bytes = [Convert]::FromBase64String($cert_content)
$cert_path = "certificate.pfx"
[IO.File]::WriteAllBytes($cert_path, $cert_bytes)
shell: pwsh
- name: Sign Executable
run: |
$cert_path = "certificate.pfx"
$password = "${{ secrets.CERT_PASSWORD }}"
$timestamp_url = "http://timestamp.digicert.com"
$executable_path = ".\AzerothAuctionAssassin-windows\AzerothAuctionAssassin\bin\Release\net8.0-windows\publish\win-x86\AzerothAuctionAssassin.exe"
$signtoolPath = Resolve-Path "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | Select-Object -Last 1
& $signtoolPath sign /f $cert_path /p $password /tr $timestamp_url /td sha256 /fd sha256 /v $executable_path
shell: pwsh
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: "v${{env.AAA_VERSION}}"
release_name: "Release v${{env.AAA_VERSION}}"
draft: false
prerelease: false
- name: Encode and Save Upload URL as Base64
id: b64encode_upload_url
run: echo "::set-output name=upload_url_base64::$(echo -n '${{ steps.create_release.outputs.upload_url }}' | base64 --wrap=0)"
- name: Upload Executable to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: .\AzerothAuctionAssassin-windows\AzerothAuctionAssassin\bin\Release\net8.0-windows\publish\win-x86\AzerothAuctionAssassin.exe
asset_name: AzerothAuctionAssassin.exe
asset_content_type: application/octet-stream
build-mac:
needs: build-windows
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: Install dependencies
run: pip install -r requirements.in
- name: Build macOS executable
run: |
python -m pip install pyinstaller
pyinstaller --onefile --add-data "AzerothAuctionAssassinData:./AzerothAuctionAssassinData" --add-data "utils:./utils" --add-data "icon.png:." --icon=icon.ico AzerothAuctionAssassin.py
chmod +x ./dist/AzerothAuctionAssassin
- name: Decode macOS Certificate
run: |
echo "${{ secrets.CERT_BASE64 }}" | base64 -d > certificate.p12
### broken probably needs a different cert
# - name: Sign macOS Executable
# run: |
# security create-keychain -p "" build.keychain
# security default-keychain -s build.keychain
# security unlock-keychain -p "" build.keychain
# security import certificate.p12 -k build.keychain -P ${{ secrets.CERT_PASSWORD }} -T /usr/bin/codesign
# codesign --deep --force --verify --verbose --sign "Developer ID Application" dist/AzerothAuctionAssassin
# - name: Upload macOS Executable to Release
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.build-windows.steps.create_release.outputs.upload_url }}
# asset_path: ./dist/AzerothAuctionAssassin
# asset_name: AzerothAuctionAssassin-macOS
# asset_content_type: application/octet-stream
# Step to decode Base64 upload URL
- name: Decode Upload URL
run: |
echo "decoded_upload_url=$(echo ${{ needs.build-windows.outputs.upload_url_base64 }} | base64 --decode)" >> $GITHUB_ENV
- name: Upload macOS Executable to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.decoded_upload_url }}
asset_path: ./dist/AzerothAuctionAssassin
asset_name: AzerothAuctionAssassin-macOS
asset_content_type: application/octet-stream