-
Notifications
You must be signed in to change notification settings - Fork 3
128 lines (107 loc) · 3.11 KB
/
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Publish
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
jobs:
build:
runs-on: 'ubuntu-latest'
environment: release
permissions:
contents: write
id-token: write
strategy:
matrix:
platform:
- macosx_10_4_x86_64
- macosx_11_0_arm64
- manylinux_2_17_x86_64
- manylinux_2_17_armv7l
- manylinux_2_17_aarch64
- win_amd64
steps:
- uses: actions/checkout@v3
# Need more than a shallow clone to get version from tags
with:
fetch-depth: 2
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build virtualenv
- name: Build wheels
run: python -m build --wheel --outdir wheelhouse
env:
PLAT_NAME: ${{ matrix.platform }}
- name: Build source distribution
run: python -m build --sdist --outdir wheelhouse
if: matrix.platform == 'manylinux_2_17_x86_64'
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*
deploy:
runs-on: 'ubuntu-latest'
environment: release
needs: [ build ]
permissions:
contents: write
id-token: write
steps:
- name: Clone repository
uses: actions/checkout@v3
# Need depth to get diff for changelog
with:
fetch-depth: 1
- name: Download dist artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
# PyPI package
- name: Publish Python package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: wheelhouse/
# Documentation
- name: Install doc dependencies
run: |
pip install -r requirements.txt
pip install -r docs/requirements.txt
- name: Build documentation
run: |
python -m sphinx docs/ docs/_build/ -b html
- name: Deploy documentation to Github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build
# Github release
- name: Read CHANGELOG
id: changelog
run: |
# Get bullet points from last CHANGELOG entry
CHANGELOG=$(git diff -U0 HEAD^ HEAD | grep '^[+][\* ]' | sed 's/\+//')
echo "Got changelog: $CHANGELOG"
# Support for multiline, see
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
{
echo 'body<<EOF'
echo "$CHANGELOG"
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Create release on Github
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.body }}