This repository was archived by the owner on Dec 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 214
142 lines (139 loc) · 4.86 KB
/
main.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
name: Package tests
on:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
branches:
- master
jobs:
test:
name: ${{ matrix.os }}, Python ${{ matrix.python_version }} (${{ matrix.python_arch }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
python_version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
python_arch:
- x64
include:
- os: windows-latest
python_version: '3.7'
python_arch: x86
- os: windows-latest
python_version: '3.8'
python_arch: x86
- os: windows-latest
python_version: '3.9'
python_arch: x86
container: ${{ matrix.os == 'ubuntu-latest' && 'quay.io/pypa/manylinux2014_x86_64' || '' }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 3
- name: Install Python
if: matrix.os != 'ubuntu-latest'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python_version }}
architecture: ${{ matrix.python_arch }}
- name: Set environment variables
shell: bash
run: |
PY_TAG=${{ matrix.python_version }}
PY_TAG="${PY_TAG//.}"
if [[ $PY_TAG -lt 38 ]]; then
PY_TAG_FULL="cp${PY_TAG}-cp${PY_TAG}m"
else
PY_TAG_FULL="cp${PY_TAG}-cp${PY_TAG}"
fi
if [[ ${{ matrix.os }} == "ubuntu-latest" ]]; then
PLAT_NAME=manylinux2014_x86_64
elif [[ ${{ matrix.os }} == "windows-latest" ]]; then
if [[ ${{ matrix.python_arch }} == "x64" ]]; then
PLAT_NAME=win_amd64
else
PLAT_NAME=win32
fi
else
PLAT_NAME=macosx_10_9_x86_64
fi
PACKAGE_VERSION=$(python -c "import lightning;print(lightning.__version__)")
echo "PY_TAG=$PY_TAG" >> $GITHUB_ENV
echo "PY_TAG_FULL=$PY_TAG_FULL" >> $GITHUB_ENV
echo "PLAT_NAME=$PLAT_NAME" >> $GITHUB_ENV
echo "PACKAGE_NAME=sklearn_contrib_lightning" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Modify PATH variable
if: matrix.os == 'ubuntu-latest'
run: echo "/opt/python/${{ env.PY_TAG_FULL }}/bin" >> $GITHUB_PATH
- name: Check Python location
if: matrix.os == 'ubuntu-latest'
shell: bash
run: |
if [[ $(which python) != "/opt/python/${{ env.PY_TAG_FULL }}/bin/python" ]]; then
exit -1
fi
- name: Check Python version
shell: python
run: |
import struct
import sys
assert sys.version_info[:2] == tuple(map(int, "${{ matrix.python_version }}".split(".")))
assert f"x{struct.calcsize('P') * 8}".replace("32", "86") == "${{ matrix.python_arch }}"
- name: Install package
run: |
python -m pip install --upgrade pip
pip install -r requirements_build.txt -r requirements_test.txt
python setup.py install
- name: Run tests
run: pytest -v --pyargs lightning
- name: Create archive with sources
if: matrix.os == 'ubuntu-latest' && matrix.python_version == '3.10' && startsWith(github.ref, 'refs/tags/')
run: python setup.py sdist
- name: Create wheels
if: startsWith(github.ref, 'refs/tags/')
run: |
pip install wheel
python setup.py bdist_wheel --python-tag="cp${{ env.PY_TAG }}" --plat-name=${{ env.PLAT_NAME }}
- name: Run auditwheel
if: matrix.os == 'ubuntu-latest' && startsWith(github.ref, 'refs/tags/')
run: |
pip install auditwheel
auditwheel repair --plat ${{ env.PLAT_NAME }} dist/${{ env.PACKAGE_NAME }}*.whl
mv -f wheelhouse/${{ env.PACKAGE_NAME }}*.whl dist/${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION }}-${{ env.PY_TAG_FULL }}-${{ env.PLAT_NAME }}.whl
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.PACKAGE_VERSION }}
name: ${{ env.PACKAGE_VERSION }}
draft: false
prerelease: false
files: |
dist/${{ env.PACKAGE_NAME }}*.whl
dist/*.tar.gz
- name: Create PyPI Release
if: startsWith(github.ref, 'refs/tags/')
shell: bash
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
pip install twine
rm -f dist/*.egg
twine upload --skip-existing dist/*