-
Notifications
You must be signed in to change notification settings - Fork 22
106 lines (100 loc) · 3.02 KB
/
build_and_publish.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
name: build-and-publish
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
pyver: [cp38, cp39, cp310, cp311, cp312]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "true"
- name: Build wheels and test
uses: pypa/cibuildwheel@v2.16.4
env:
CIBW_BUILD: ${{ matrix.pyver }}-*
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}-${{ matrix.pyver }}-${{ strategy.job-index }}
path: wheelhouse/*
build-sdist:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: "true"
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install pypa/build
run: "python -m pip install build --user"
- name: Build a source tarball
run: "python -m build --sdist"
- name: Upload sdist artifacts
uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*
trigger-build-doc:
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
steps:
- name: Trigger ReadTheDocs build
uses: dfm/rtds-action@v1
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ github.ref }}
nightly-release:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/') # if a commit is pushed
needs: [build, build-sdist]
runs-on: ubuntu-latest
permissions:
contents: write # create nightly release
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: Update Nightly Release
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: nightly
name: 'Nightly Release'
prerelease: true
body: 'MPlib development nightly release. This release is mainly for internal testing. Stable releases are published to pypi https://pypi.org/p/mplib/'
files: |
dist/*
publish-pypi:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') # if a tag is pushed
needs: [build, build-sdist]
runs-on: ubuntu-latest
environment: pypi_publish
permissions:
id-token: write # mandatory for PyPI trusted publishing
steps:
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
path: dist/
merge-multiple: true
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist/