-
Notifications
You must be signed in to change notification settings - Fork 45
169 lines (138 loc) · 5.5 KB
/
build-wheels.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
name: Build Wheels
on:
workflow_dispatch:
inputs:
requested_release_tag:
description: 'The tag to use for this release (e.g., `v2.3.1`)'
required: true
jobs:
sanity_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.12'
- run: |
pip install packaging
- name: Normalize the release version
run: |
echo "release_version=`echo '${{ github.event.inputs.requested_release_tag }}' | sed 's/^v//'`" >> $GITHUB_ENV
- name: Normalize the release tag
run: |
echo "release_tag=v${release_version}" >> $GITHUB_ENV
- name: Get the VERSION from setup.py
run: |
echo "ciso8601_version=`grep -Po 'VERSION = "\K[^"]*' setup.py`" >> $GITHUB_ENV
- name: Get the latest version from PyPI
run: |
curl https://pypi.org/pypi/ciso8601/json | python -c 'import json, sys; contents=sys.stdin.read(); parsed = json.loads(contents); print("pypi_version=" + parsed["info"]["version"])' >> $GITHUB_ENV
- name: Log all the things
run: |
echo 'Requested release tag `${{ github.event.inputs.requested_release_tag }}`'
echo 'Release version `${{ env.release_version }}`'
echo 'Release tag `${{ env.release_tag }}`'
echo 'VERSION in setup.py `${{ env.ciso8601_version }}`'
echo 'Version in PyPI `${{ env.pypi_version }}`'
- name: Verify that the version string we produced looks like a version string
run: |
echo "${{ env.release_version }}" | sed '/^[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}'
- name: Verify that the version tag we produced looks like a version tag
run: |
echo "${{ env.release_tag }}" | sed '/^v[0-9]\+\.[0-9]\+\.[0-9]\+$/!{q1}'
- name: Verify that the release version matches the VERSION in setup.py
run: |
[[ ${{ env.release_version }} == ${{ env.ciso8601_version }} ]]
- name: Verify that the `release_version` is larger/newer than the existing release in PyPI
run: |
python -c 'import sys; from packaging import version; code = 0 if version.parse("${{ env.pypi_version }}") < version.parse("${{ env.release_version }}") else 1; sys.exit(code)'
- name: Verify that the `release_version` is present in the CHANGELOG
# TODO: Use something like `changelog-cli` to extract the correct version number
run: |
grep ${{ env.release_version }} CHANGELOG.md
- name: Serialize normalized release values
run: |
echo -e "release_version=${{ env.release_version }}\nrelease_tag=${{ env.release_tag }}" > release_values.txt
- name: Share normalized release values
uses: actions/upload-artifact@v3
with:
name: release_values
path: release_values.txt
build_wheels:
name: Build wheel on ${{ matrix.os }}
needs: [sanity_check]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Build wheels
uses: closeio/[email protected]
env:
CIBW_SKIP: "pp*-macosx* *-win32 *-manylinux_i686"
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: Build source distribution
needs: [sanity_check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.12'
- name: Get build tool
run: pip install --upgrade build
- name: Build sdist
run: python -m build
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
# create_or_update_draft_release:
# # TODO: Figure out how to do this in an idempotent way
# name: Create or update draft release in GitHub
# needs: [build_wheels, build_sdist, sanity_check]
# runs-on: ubuntu-latest
# steps:
# - name: Get normalized release values
# uses: actions/download-artifact@v2
# with:
# name: release_values
# - name: Load normalized release values
# run: |
# xargs -a release_values.txt -l -I{} bash -c 'echo {} >> $GITHUB_ENV'
# - uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
# with:
# tag_name: ${{ env.release_tag }}
# commitish: master # Default branch
# release_name: ${{ env.release_tag }}
# body: "" # TODO: Pull this in using `changelog-cli`
# draft: true
# upload_to_pypi:
# name: Upload wheels to PyPI
# needs: [build_wheels, build_sdist, sanity_check]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v2
# with:
# name: artifact
# path: dist
# - uses: closeio/[email protected]
# with:
# user: __token__
# password: ${{ secrets.PYPI_PASSWORD }}
# # repository_url: https://test.pypi.org/legacy/ # Test PyPI
# create_release:
# name: Create release in GitHub
# needs: [upload_to_pypi]
# runs-on: ubuntu-latest
# steps: # TODO
# - run: |
# echo "We're doing a release!? ${{ github.event }}"