-
Notifications
You must be signed in to change notification settings - Fork 3
183 lines (162 loc) · 5.79 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Test and release
on:
push:
branches:
- 'release/*'
- 'develop'
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: 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 && python -m pip install torch && cd tests && python -m pytest
linux: rm -rf MLXP && python -m pip install pytest && python -m pip install torch && cd tests && python -m pytest
windows: Remove-Item -Force -Recurse MLXP && python -m pip install pytest && python -m pip install torch && cd tests && python -m pytest
upload_pypi:
if: 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 }}
update-master:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Check if release is made and branch is latest release branch
run: |
latest_release_branch=$(git branch --list 'release/*' --sort=-version:refname | head -n1 | cut -d' ' -f2)
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "${current_branch}" == "${latest_release_branch}" ]]; then
git fetch
git push --force origin $latest_release_branch:master
else
echo "No release made or branch is not latest release branch"
exit 1
fi