-
Notifications
You must be signed in to change notification settings - Fork 11
168 lines (138 loc) · 4.64 KB
/
packaging.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
# Copyright 2021-2023 Jetperch LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# GitHub actions
# See documentation: https://docs.github.com/en/actions
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
# CMake example: https://github.com/Mizux/cmake-cpp/blob/main/.github/workflows/amd64_windows.yml
name: Packaging
on: ['push', 'pull_request']
env:
PYTHON_VERSION: '3.11'
jobs:
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- name: Display info
run: |
echo "github.event_name=$GITHUB_EVENT_NAME"
echo "github.ref=$GITHUB_REF"
echo "github.ref_type=$GITHUB_REF_TYPE"
echo "runner.os=$RUNNER_OS"
echo "runner.arch=$RUNNER_ARCH"
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Display version
run: python -VV
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel pytest
- name: Build sdist
run: python -m build --sdist
- name: Install the wheel
run: python -m pip install -f dist pymonocypher
- name: Run python unit tests
run: pytest
- name: Upload python source package
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error
build_wheels:
name: Build on ${{ matrix.os }}, python=${{ matrix.python_version }}
needs:
- build_sdist
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
python_version: ["cp39", "cp310", "cp311", "cp312"]
exclude:
- os: "macos-latest"
python_version: "cp39"
steps:
- name: Download sdist
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
- name: Find sdist filename
shell: bash
id: find_sdist_filename
run: echo "filename=$(ls dist/*.tar.gz)" >> $GITHUB_OUTPUT
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.17.0
- name: Build wheels
env:
CIBW_ARCHS_MACOS: universal2
CIBW_ARCHS_WINDOWS: native
CIBW_ARCHS_LINUX: native
# skip PyPy: Cython only supports CPython
# skip musllinux: build takes too long with default os images.
CIBW_SKIP: 'pp* *musllinux*'
CIBW_BUILD: '${{ matrix.python_version }}-*'
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}/test
run: python -m cibuildwheel ${{ steps.find_sdist_filename.outputs.filename }}
- name: Upload python wheels
uses: actions/upload-artifact@v4
with:
name: python_wheel-${{ matrix.os }}-${{ matrix.python_version }}
path: wheelhouse/*.whl
if-no-files-found: error
publish_python:
name: Publish python packages to PyPi
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v')
needs:
- build_sdist
- build_wheels
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
- name: Download python sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist
path: dist/
- name: Download python wheel artifacts
uses: actions/download-artifact@v4
with:
pattern: python_wheel-*
merge-multiple: true
path: dist/
- name: Display artifacts
shell: bash
run: ls dist/*
- name: Publish packages to PyPi
uses: pypa/[email protected]
with:
print-hash: true
- name: Publish Release assets
uses: softprops/action-gh-release@v1
with:
files: |
dist/*