-
-
Notifications
You must be signed in to change notification settings - Fork 220
193 lines (173 loc) · 6.07 KB
/
build-wheel.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Build wheel
on:
release:
types: [created]
workflow_call:
workflow_dispatch:
jobs:
build_wheel:
strategy:
fail-fast: false
matrix:
# macos-14 is arm64 (apple silicon), macos-13 is x86_64
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
name: Build [${{ matrix.os }}]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: |
**/requirements.txt
**/requirements-dev.txt
- name: Set up QEMU
if: runner.os == 'Linux' && github.event_name != 'pull_request'
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,ppc64le
- name: Install build tools
run: uv pip install --system -r requirements-dev.txt
- name: Bump new dev version
if: github.event_name != 'release'
run: |
git config user.name "Marcelo Duarte"
git config user.email marcelotduarte@users.noreply.github.com
SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
VERSION=$(bump-my-version show current_version 2>/dev/null)
VERSION_BASE=$(python -c "print('$VERSION'.rsplit('-',1)[0])")
if [ "${{ github.event_name }}" == "pull_request" ]; then
OPTIONAL=".${{ github.event.number }}"
else
OPTIONAL=""
fi
VERSION_NEW=$VERSION_BASE$OPTIONAL-dev.$SOURCE_DATE_EPOCH
bump-my-version bump --no-tag build --new-version=$VERSION_NEW 2>/dev/null
git log -1
- name: Build sdist and wheels
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
if [ "${{ github.event_name }}" == "pull_request" ]; then
./ci/build-wheel.sh "cp3{9,10,11,12,13}-manylinux*" --archs="x86_64"
else
./ci/build-wheel.sh --all
fi
elif [ "${{ matrix.os }}" == "macos-13" ]; then
./ci/build-wheel.sh "cp3{9,10}-*"
elif [ "${{ matrix.os }}" == "macos-14" ]; then
if [ "${{ github.event_name }}" == "pull_request" ]; then
./ci/build-wheel.sh "cp3{11,12}-*" --archs="arm64"
else
./ci/build-wheel.sh "cp3{11,12}-*"
fi
else
if [ "${{ github.event_name }}" == "pull_request" ]; then
./ci/build-wheel.sh "cp3{9,10,11,12,13}-*" --archs="AMD64"
else
./ci/build-wheel.sh --all
fi
fi
- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: cx-freeze-whl-${{ matrix.os }}
path: wheelhouse
compression-level: 0 # no compression
testpypi:
name: Publish package to TestPyPI
if: github.event_name == 'workflow_dispatch'
needs:
- build_wheel
runs-on: ubuntu-latest
environment:
name: ${{ github.event_name }}
url: https://test.pypi.org/p/cx-Freeze
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: wheelhouse
pattern: cx-freeze-whl-*
merge-multiple: true
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
publish:
name: Publish package to PyPI
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
needs:
- build_wheel
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/cx-Freeze
permissions:
id-token: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: wheelhouse
pattern: cx-freeze-whl-*
merge-multiple: true
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
skip-existing: true
verbose: true
update_bases:
name: Update cx_Freeze/bases and util module
needs:
- build_wheel
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
repository: marcelotduarte/cx_Freeze
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: wheelhouse
pattern: cx-freeze-whl-windows-*
merge-multiple: true
- name: If changed, extract and update the base executables and util module
run: |
SHA256SUM1=$(cat source/*.c source/bases/* | sha256sum | awk '{print $1}')
SHA256SUM2=$(cat cx_Freeze/bases/__init__.py | awk '{print $2}')
if [ $SHA256SUM1 != $SHA256SUM2 ]; then
git config user.name "Marcelo Duarte"
git config user.email marcelotduarte@users.noreply.github.com
git checkout -B update_bases main
# Remove any file that match - remove previous versions too
git rm --ignore-unmatch 'cx_Freeze/bases/*-win*.exe' 'cx_Freeze/util.*-win*.pyd'
# Extract base executables and util module
for file in wheelhouse/*.whl; do
unzip -o $file 'cx_Freeze/bases/*-win*.exe' 'cx_Freeze/util.*-win*.pyd'
done
git add cx_Freeze/bases/*-win*.exe cx_Freeze/util.*-win*.pyd
# Save the new SHA256SUM
echo "# $SHA256SUM1" > cx_Freeze/bases/__init__.py
git add cx_Freeze/bases/__init__.py
# Update
git commit -m "bases: update base executables and util module [ci skip]"
git push origin update_bases
fi