Skip to content

Commit 752254d

Browse files
committed
Add cibuildwheel actions to main
1 parent e67b917 commit 752254d

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
tags:
6+
# ytf did they invent their own syntax that's almost regex?
7+
# ** matches 'zero or more of any character'
8+
- 'release-v[0-9]+.[0-9]+.[0-9]+**'
9+
- 'prerelease-v[0-9]+.[0-9]+.[0-9]+**'
10+
jobs:
11+
build_wheels:
12+
name: Build wheels on ${{ matrix.os }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
# macos-13 is an intel runner, macos-14 is apple silicon
17+
os: [ubuntu-latest, windows-latest, macos-13]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Build wheels
22+
uses: pypa/cibuildwheel@v2.19.1
23+
env:
24+
CIBW_SOME_OPTION: value
25+
with:
26+
package-dir: .
27+
output-dir: wheelhouse
28+
config-file: "{package}/pyproject.toml"
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
32+
path: ./wheelhouse/*.whl
33+
34+
build_sdist:
35+
name: Build source distribution
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Build sdist
41+
run: pipx run build --sdist
42+
- uses: actions/upload-artifact@v4
43+
with:
44+
name: cibw-sdist
45+
path: dist/*.tar.gz
46+
create_release:
47+
needs: [build_wheels, build_sdist]
48+
runs-on: ubuntu-latest
49+
permissions:
50+
contents: write
51+
checks: write
52+
actions: read
53+
issues: read
54+
packages: write
55+
pull-requests: read
56+
repository-projects: read
57+
statuses: read
58+
steps:
59+
- name: Get the tag name and determine if it's a prerelease
60+
id: get_tag_info
61+
run: |
62+
FULL_TAG=${GITHUB_REF#refs/tags/}
63+
if [[ $FULL_TAG == release-* ]]; then
64+
TAG_NAME=${FULL_TAG#release-}
65+
IS_PRERELEASE=false
66+
elif [[ $FULL_TAG == prerelease-* ]]; then
67+
TAG_NAME=${FULL_TAG#prerelease-}
68+
IS_PRERELEASE=true
69+
else
70+
echo "Tag does not match expected patterns" >&2
71+
exit 1
72+
fi
73+
echo "FULL_TAG=$TAG_NAME" >> $GITHUB_ENV
74+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
75+
echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_ENV
76+
- uses: actions/download-artifact@v4
77+
with:
78+
# unpacks all CIBW artifacts into dist/
79+
pattern: cibw-*
80+
path: dist
81+
merge-multiple: true
82+
- name: Create Draft Release
83+
id: create_release
84+
uses: softprops/action-gh-release@v2
85+
if: startsWith(github.ref, 'refs/tags/')
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
with:
89+
name: ${{ env.TAG_NAME }}
90+
draft: true
91+
prerelease: ${{ env.IS_PRERELEASE }}
92+
files: "./dist/*"

.github/workflows/publish_pypi.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# The cibuildwheel action triggers on creation of a release, this
2+
# triggers on publication.
3+
# The expected workflow is to create a draft release and let the wheels
4+
# upload, and then hit 'publish', which uploads to PyPi.
5+
6+
on:
7+
release:
8+
types:
9+
- published
10+
11+
jobs:
12+
upload_pypi:
13+
runs-on: ubuntu-latest
14+
environment:
15+
name: pypi
16+
url: https://pypi.org/p/thinc
17+
permissions:
18+
id-token: write
19+
contents: read
20+
if: github.event_name == 'release' && github.event.action == 'published'
21+
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
22+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
23+
steps:
24+
- uses: robinraju/release-downloader@v1
25+
with:
26+
tag: ${{ github.event.release.tag_name }}
27+
fileName: '*'
28+
out-file-path: 'dist'
29+
- uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)