-
Notifications
You must be signed in to change notification settings - Fork 45
168 lines (144 loc) · 5.39 KB
/
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
# Build sdist+wheel packages using GitHub Actions. Mostly adopted
# from https://cibuildwheel.readthedocs.io/en/stable/setup/
name: "Packages"
on:
push:
branches:
# Do build on pushes to master.
- "master"
tags:
# Do build on pushes to any release tag See
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
# for documentation about how patterns are matched.
- "zfec-*"
# Do build on pushes to any branch with an open pull request.
pull_request:
# Do build on different release events
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release
release:
types: [published, created, edited]
jobs:
build_wheels:
name: "${{ matrix.wheel-selector }} wheel on ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
# NOTE: when updating the matrix below, be sure to keep OS and
# Python versions in sync with the ones in test.yml.
matrix:
os:
- "macos-11"
- "ubuntu-22.04"
- "windows-2022"
wheel-selector:
- "cp38-*"
- "cp39-*"
- "cp310-*"
- "cp311-*"
- "cp312-*"
- "pp37-*"
- "pp38-*"
- "pp39-*"
steps:
- name: Check out zfec sources
uses: actions/checkout@v3
with:
# Check out the full history, including tags. This is necessary to
# construct non-release version numbers.
fetch-depth: 0
- name: Build wheels
uses: pypa/[email protected]
with:
output-dir: wheelhouse
env:
# Configure cibuildwheel to build just some of the total wheels we
# could build for this architecture. This yields better parallelism
# on GitHub Actions execution.
CIBW_BUILD: "${{ matrix.wheel-selector }}"
# Just make sure that Python can use zfec package.
CIBW_TEST_COMMAND: python -c "import zfec; print(zfec.__version__)"
# Build `universal2` and `arm64` wheels on an Intel runner.
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
# Skip testing arm64 builds on Intel Macs.
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
- uses: actions/upload-artifact@v3
name: Upload artifacts
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Check out zfec sources
with:
# Check out the full history, including tags. This is necessary to
# construct non-release version numbers.
fetch-depth: 0
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.11'
- name: Build sdist
run: |
python3 setup.py sdist
- uses: actions/upload-artifact@v3
name: Upload artifacts
with:
path: dist/*.tar.gz
upload_pypi:
needs:
- "build_wheels"
- "build_sdist"
# It only needs to run once. It will fetch all of the other build
# artifacts created by the other jobs and then upload them.
runs-on: "ubuntu-latest"
# Select the GitHub Actions environment that contains the PyPI tokens
# necessary to perform uploads. This was configured manually using the
# GitHub web interface.
environment: "release"
steps:
# Download all artifacts previously built by this workflow to the dist
# directory where the publish step can find them. These are the sdist
# and all of the wheels build by the other jobs.
- uses: "actions/download-artifact@v3"
with:
name: "artifact"
path: "dist"
# Define a conditional step to upload packages to the testing instance
# of PyPI.
#
# The overall workflow is already restricted so that it runs for:
# 1) pushes to master
# 2) pushes to release tags
# 3) pushes to branches with associated PRs
#
# The conditional in this step should cause it to run only for case (3).
- name: "Publish to TEST PyPI"
uses: "pypa/[email protected]"
if: >-
github.event_name == 'pull_request'
with:
# Authenticate using a token from a PyPI account with upload
# permission to the project. See https://pypi.org/help/#apitoken
user: "__token__"
# Read it from a GitHub Actions "environment" secret. See
# https://docs.github.com/en/actions/security-guides/encrypted-secrets
password: "${{ secrets.testpypi_token }}"
# Override the default in order to upload it to the testing
# deployment.
repository_url: "https://test.pypi.org/legacy/"
# Now define a conditional step to upload packages to the production
# instance of PyPI.
#
# The cases to consider are the same as for the upload to the testing
# instance. This time, we have a conditional that runs only for case
# (2).
- name: "Publish to LIVE PyPI"
uses: "pypa/[email protected]"
if: >-
github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags/zfec-')
with:
user: "__token__"
password: "${{ secrets.pypi_token }}"