-
-
Notifications
You must be signed in to change notification settings - Fork 56
136 lines (127 loc) · 4.2 KB
/
build-python-wheels.yml
File metadata and controls
136 lines (127 loc) · 4.2 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Python Packages
on:
pull_request:
branches: [develop]
push:
branches: [develop]
tags: ["v*"]
permissions:
contents: read
jobs:
build-wheels:
name: build wheels using cibuildwheel
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v6.0.2
- name: download dictionary for PGO
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-24.04-arm' }}
run: bash fetch_dictionary.sh "20220519" "core" "8de60382bde6b8307a10daa265569164a6296b28d52d793c3ed0757786969365"
- uses: actions/cache@v5.0.5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: cibuildwheel ${{ matrix.os }}
uses: pypa/cibuildwheel@v3.4.1
with:
package-dir: .
output-dir: python/dist
config-file: pyproject.toml
extras: "uv"
- uses: actions/upload-artifact@v7.0.1
with:
name: artifact-${{ matrix.os }}
path: |
./python/dist/*.whl
./python/dist/*.tar.gz
build-sdist:
name: build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: setup python for sdist
uses: actions/setup-python@v6.2.0
with:
python-version: "3.11"
- name: Setup uv
uses: astral-sh/setup-uv@v8.1.0
- uses: actions/cache@v5.0.5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: build sdist
working-directory: ./python
run: bash build-sdist.sh
- uses: actions/upload-artifact@v7.0.1
with:
name: artifact-sdist
path: |
./python/dist/*.whl
./python/dist/*.tar.gz
verify-artifacts:
name: verify distribution artifacts
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- name: Setup python
uses: actions/setup-python@v6.2.0
with:
python-version: "3.11"
- uses: actions/download-artifact@v8.0.1
with:
pattern: artifact-*
path: dist/
merge-multiple: true
- name: List artifacts
run: ls -R dist/
- name: Check version metadata
run: python python/check_version_consistency.py
- name: Install artifact check tools
run: python -m pip install -U pip twine check-wheel-contents
- name: Check metadata and wheel contents
run: |
twine check dist/*
check-wheel-contents dist/*.whl
python python/verify-dist-artifacts.py dist
- name: Install wheel smoke test
run: |
python -m venv /tmp/sudachipy-artifact-smoke
/tmp/sudachipy-artifact-smoke/bin/python -m pip install -U pip
/tmp/sudachipy-artifact-smoke/bin/python -m pip install --no-index --only-binary SudachiPy --find-links dist SudachiPy
/tmp/sudachipy-artifact-smoke/bin/python -c "import sudachipy; print(sudachipy.__version__)"
/tmp/sudachipy-artifact-smoke/bin/sudachipy --help
upload-to-pypi: # run only if all have succeeded
needs: [verify-artifacts]
# https://stackoverflow.com/questions/58475748/github-actions-how-to-check-if-current-push-has-new-tag-is-new-release
if: startsWith(github.ref, 'refs/tags/v') # only for tags
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: read
id-token: write
steps:
- uses: actions/download-artifact@v8.0.1
with:
pattern: artifact-*
path: dist/
merge-multiple: true
- name: List files to upload
run: ls -R dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.0
with:
verbose: true