This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
forked from htm-community/htm.core
-
Notifications
You must be signed in to change notification settings - Fork 0
211 lines (172 loc) · 6.46 KB
/
release.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
name: Release
#TODO arm releases
#TODO enable 32bit linux wheels builds?
#TODO use older manylinux2010 for larger compatibility?
#TODO enable python 3.8 builds for CIBW
#TODO support py27 wheels?
on:
push:
tags:
- 'v*.*.*' # when tag with name 'vX.Y.Z' is pushed to master
release: # or when a new Release is created&published in GH web interface
types: [published]
jobs:
build-release-gh: # do a release build for GH Releases, C++ binary
name: Building on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
#max-parallel: 4
matrix:
python-version: [3.7] #TODO we're not yet py3.8 ready!
os: [ubuntu-18.04, windows-2019, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Versions
run: |
python --version
cmake --version
c++ --version
- name: Install gcc-8
if: matrix.os == 'ubuntu-18.04'
run: |
sudo apt-get update
sudo apt-get -y install gcc-8 g++-8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 \
100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-8 \
--slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-8 \
--slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-8 \
--slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-8 \
--slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-8 \
--slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-8
sudo update-alternatives --install /usr/bin/cpp cpp-bin /usr/bin/cpp-8 100
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
python setup.py configure
- name: build htmcore with setup.py
run: python setup.py install --user --force
- name: C++ & Python Tests
run: python setup.py test
- name: Release (make package)
run: |
python setup.py bdist_wheel
cd build/scripts
cmake --build . --config Release --target install # aka make install ,but multiplatform
cmake --build . --config Release --target package # make package
- name: GitHub Release C++ (deploy)
# from https://github.com/marketplace/actions/gh-release
uses: softprops/action-gh-release@v1
with:
files: |
build/scripts/htm_core-v*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v2
with:
name: "release"
path: build/Release/distr/dist
build-wheels: # this is a separate job from build-gh-release as CIBW needs to re-build on its platform/image/python. Existing build breaks it.
name: Wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
#max-parallel: 4
matrix:
os: [ubuntu-18.04, windows-2019, macOS-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Install cibuildwheel
run: |
python -m pip install cibuildwheel
- name: Build wheel
env:
# install your project dependencies before building
CIBW_BEFORE_BUILD: "pip install -r {project}/requirements.txt"
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: "pytest {project}/py/tests {project}/bindings/py/tests"
# Only build on Python >=3.7 and skip 32-bit builds
CIBW_BUILD: cp37-*
CIBW_SKIP: "*-win32 cp27-manylinux* *i686*"
# build using the manylinux2014 image
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
MACOSX_DEPLOYMENT_TARGET: "10.15" #for C++17 compatibility in OSX, see https://cibuildwheel.readthedocs.io/en/stable/cpp_standards/#macos-and-deployment-target-versions
run: |
python -m cibuildwheel --output-dir wheelhouse
- name: Publish wheels to GitHub artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl
build-arm64-docker:
name: Build for ARM64 on Docker
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: ARM64 env
run: |
sudo docker run --privileged --rm multiarch/qemu-user-static:register
sudo docker build -t htm-arm64-docker --build-arg arch=arm64 -f Dockerfile-pypi .
uname -a
- name: Dependencies
run: |
sudo docker run htm-arm64-docker python -m pip install -r requirements.txt
- name: Build ARM64
run: |
sudo docker run htm-arm64-docker python setup.py install --force
#TODO build manylinux2014 amr linux wheel using CIBW
- name: Tests
run: |
sudo docker run htm-arm64-docker python setup.py test
- name: Copy files from docker
run: |
sudo docker cp `sudo docker ps -alq`:/usr/local/src/htm.core/dist dist #TODO the `command` is not 100% reliable, replace with some name/id
ls dist
- uses: actions/upload-artifact@v2
with:
name: "release"
path: dist/
- uses: actions/upload-artifact@v2
with:
name: "wheels"
path: dist/*.whl
- name: GitHub Release C++ (deploy)
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags'))
uses: softprops/action-gh-release@v1
with:
files: |
dist/htm_core-v*
dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-pypi: #this is a separate job, as the upload must run only once, after all wheels have been created
needs: [build-wheels]
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: wheels
path: dist/
- name: GitHub Release wheels (deploy)
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags'))
uses: softprops/action-gh-release@v1
with:
files: |
dist/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
repository_url: https://test.pypi.org/legacy/ #TODO toggle test/real pypi
packages_dir: ./dist/