-
-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (105 loc) · 3.35 KB
/
build.yml
File metadata and controls
119 lines (105 loc) · 3.35 KB
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
name: Build Executables
on:
push:
branches: ['main', 'master']
paths:
- 'get_cert.py'
- 'get_cert.spec'
- 'requirements.txt'
pull_request:
branches: ['main', 'master']
paths:
- 'get_cert.py'
- 'get_cert.spec'
- 'requirements.txt'
workflow_dispatch:
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
path: ~/.cache/pip
- os: macos-latest
path: ~/Library/Caches/pip
- os: windows-latest
path: ~\AppData\Local\pip\Cache
arch: [x64, arm64]
exclude:
# Exclude arm64 builds on ubuntu and windows for now
- os: ubuntu-latest
arch: arm64
- os: windows-latest
arch: arm64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
architecture: ${{ matrix.arch }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ matrix.path }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache Chocolatey packages
if: matrix.os == 'windows-latest'
uses: actions/cache@v4
env:
cache-name: choco-upx-cache
with:
path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
key: ${{ runner.os }}-${{ env.cache-name }}-${{ env.UPX_VERSION }}
- name: Install UPX (Windows-only)
if: matrix.os == 'windows-latest'
shell: pwsh
env:
UPX_VERSION: 4.2.4
run: |
$cachedUpx = Get-ChildItem -Path "C:\Users\runneradmin\AppData\Local\Temp\chocolatey" -Filter "upx.$env:UPX_VERSION.nupkg" -Recurse
if ($cachedUpx) {
choco install upx --version $env:UPX_VERSION --source="C:\Users\runneradmin\AppData\Local\Temp\chocolatey"
} else {
choco install upx --version $env:UPX_VERSION
}
- name: Build with PyInstaller
run: |
pyinstaller get_cert.spec --clean
- name: Create renamed archive (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
cd dist
os_lower=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')
arch_lower=$(echo ${{ matrix.arch }} | tr '[:upper:]' '[:lower:]')
zip_name="get_cert_${os_lower}_${arch_lower}.zip"
zip "$zip_name" get_cert
echo "ZIP_NAME=$zip_name" >> $GITHUB_ENV
- name: Create renamed archive (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
cd dist
$os_lower = '${{ runner.os }}'.ToLower()
$arch_lower = '${{ matrix.arch }}'.ToLower()
$zip_name = "get_cert_${os_lower}_${arch_lower}.zip"
Compress-Archive -Path get_cert.exe -DestinationPath $zip_name
echo "ZIP_NAME=$zip_name" >> $env:GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ZIP_NAME }}
path: dist/${{ env.ZIP_NAME }}