-
Notifications
You must be signed in to change notification settings - Fork 14
153 lines (127 loc) · 4.19 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
name: Build Wheels
on:
workflow_dispatch:
push:
branches:
- '**'
release:
types:
- created
- published
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
#- name: Prefix wheels with branch name
# if: startsWith(github.ref, 'refs/heads/')
# run: |
# branchName=${GITHUB_REF/refs\/heads\//}
# for file in wheelhouse/*.whl; do
# newName="${branchName}-$(basename $file)"
# mv "$file" "wheelhouse/$newName"
# done
# shell: bash
- uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/*.whl
publish_wheels_to_gh_pages:
name: Publish wheels to GitHub Pages
runs-on: ubuntu-latest
needs: build_wheels
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Copy wheels to gh-pages branch
run: |
mkdir -p gh-pages/wheels
cp wheelhouse/*.whl gh-pages/wheels/
- name: Create index.html for wheels directory
run: |
cd gh-pages/wheels
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo "<head><title>Index of wheels</title></head>" >> index.html
echo "<body>" >> index.html
echo "<h1>Index of wheels</h1>" >> index.html
echo "<ul>" >> index.html
for wheel in *.whl; do
echo "<li><a href=\"$wheel\">$wheel</a></li>" >> index.html
done
echo "</ul>" >> index.html
echo "</body>" >> index.html
echo "</html>" >> index.html
- name: Commit and push wheels to gh-pages branch
run: |
cd gh-pages
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git add wheels/*.whl wheels/index.html
git commit -m "Upload wheels to GitHub Pages and update index.html"
git push
publish_wheels_to_pypi:
name: Publish wheels to PyPI
needs: build_wheels
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse
publish_wheels_to_release_page:
name: Publish wheels to Release Page
needs: build_wheels
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- name: Get release info
uses: actions/github-script@v5
id: get_release_info
with:
script: |
const { upload_url } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.payload.release.tag_name,
});
return { upload_url: upload_url };
- name: Print upload URL
run: echo "Upload URL is ${{ steps.get_release_info.outputs.upload_url }}"
- name: Upload wheels to release assets
uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: wheelhouse/*.whl