-
Notifications
You must be signed in to change notification settings - Fork 3
161 lines (142 loc) · 5.09 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Test and release
on: push
jobs:
lint_code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 mlxp --count --select=E9,F63,F7,F82 --show-source --statistics
build_wheels:
needs: [lint_code]
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
#os: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir wheelhouse/
# - name: Build wheels
# run: python -m pip wheel --wheel-dir=wheelhouse mlxp
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')
needs: [lint_code]
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set version
run: echo "PACKAGE_VERSION=$(cat VERSION)" >> $GITHUB_ENV
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.9
# - name: Build sdist
# run: python setup.py sdist
- name: Install pypa/build
run: python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --outdir dist/
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
- name: version
run: echo "::set-output name=version::${{ env.PACKAGE_VERSION }}"
id: version
- name: release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.version }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}
- name: upload zip archive
#uses: actions/upload-release-asset@v1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/MLXP-${{ env.PACKAGE_VERSION }}.zip
asset_name: MLXP-${{ env.PACKAGE_VERSION }}.zip
asset_content_type: application/zip
- name: upload targz archive
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ steps.version.outputs.version }}
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/MLXP-${{ env.PACKAGE_VERSION }}.tar.gz
asset_name: MLXP-${{ env.PACKAGE_VERSION }}.tar.gz
asset_content_type: application/gzip
run_tests:
needs: [build_wheels]
name: Run the tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
#os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
#python-version: ['3.9']
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Try to import mlxp
run: python -m pip install --find-links dist MLXP && python -c "import mlxp;"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Switch to Current Branch
run: git checkout ${{ env.BRANCH }}
- name: Run tests without the lib
uses: knicknic/[email protected]
with:
macos: rm -rf MLXP && python -m pip install pytest && cd tests && python -m pytest
linux: rm -rf MLXP && python -m pip install pytest && cd tests && python -m pytest
windows: Remove-Item -Force -Recurse MLXP && python -m pip install pytest && cd tests && python -m pytest
upload_pypi:
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')
needs: [build_wheels, build_sdist, run_tests]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}