-
Notifications
You must be signed in to change notification settings - Fork 106
101 lines (88 loc) · 2.67 KB
/
pypi.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
name: Upload to PyPI
on:
push:
tags:
- "v[0-9]+.*"
- "test-v[0-9]+.*" # Uploads to https://test.pypi.org/project/tree-sitter/
jobs:
build-sdist:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-11, windows-2022]
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- if: ${{ startsWith(matrix.os, 'windows') }}
run: script\fetch-fixtures.cmd
- if: ${{ !startsWith(matrix.os, 'windows') }}
run: script/fetch-fixtures
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
# Build wheels
- run: pip install cibuildwheel==2.16.1
- run: python -m cibuildwheel --output-dir dist
env:
CIBW_TEST_COMMAND: python -m unittest discover -s {package}/tests
CIBW_ARCHS_MACOS: x86_64 arm64 universal2
CIBW_ARCHS_LINUX: x86_64 aarch64
# Make wheels downloadable from GitHub UI and from the pypi step
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./dist/*.whl
release:
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- run: ls -la
- run: ls -la dist
# https://stackoverflow.com/a/58478262
- if: ${{ startsWith(github.ref, 'refs/tags/test-v') }}
name: "Upload to test.pypi.org"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: "Upload to pypi.org"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- if: ${{ startsWith(github.ref, 'refs/tags/v') }}
name: "Create GitHub Release"
uses: softprops/action-gh-release@v1
with:
draft: false
prerelease: false
files: |
dist/*.whl
dist/*.tar.gz
generate_release_notes: true