-
Notifications
You must be signed in to change notification settings - Fork 10
164 lines (143 loc) · 5.2 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
name: Build
on:
push:
branches:
- master
- devel
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+a[0-9]+'
pull_request:
branches:
- master
- devel
schedule:
# https://crontab.guru/#0_8_*_*_1
- cron: '0 8 * * 1'
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# windows is tested on azure for now
os: [ubuntu-20.04, windows-2019, macos-11]
steps:
- uses: actions/checkout@v3
- name: Install SWIG
if: runner.os == 'Windows'
run: choco install swig -f -y
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all
- name: Get versions
id: version
run: |
python -m pip install requests
echo "::set-output name=glpk_version::$(python scripts/find_newest_glpk_release.py)"
echo "::set-output name=swigplk_version::$(python scripts/find_swiglpk_version.py)"
- name: Build wheels
uses: joerick/[email protected]
env:
NEW_GLPK_VERSION: ${{ steps.version.outputs.glpk_version }}
GLPK_HEADER_PATH: glpk-${{ steps.version.outputs.glpk_version }}/src
CIBW_ENVIRONMENT_LINUX: GLPK_HEADER_PATH=/include
CIBW_ENVIRONMENT_MACOS: PATH=$PATH:/usr/local/bin LDFLAGS="-L/usr/local/lib $LDFLAGS" LD_LIBRARY_PATH="/usr/local/lib"
# install swig before build in each python environment
# each job runs a python environment so this is equivalent to CIBW_BEFORE_ALL
CIBW_BEFORE_BUILD_LINUX: source {project}/config.sh && pre_build
CIBW_BEFORE_BUILD_MACOS: source {project}/config.sh && IS_OSX=true pre_build
CIBW_BEFORE_BUILD_WINDOWS: rm -rf glpk_build && python scripts/build_glpk.py
CIBW_ARCHS_MACOS: "arm64 x86_64"
CIBW_ARCHS_LINUX: "auto aarch64"
CIBW_SKIP: pp*-win* *-musllinux* cp36-*_aarch64 cp37-*_aarch64 pp*-*_aarch64
# install before tests
CIBW_TEST_COMMAND: cp {project}/test_swiglpk.py . && python test_swiglpk.py
CIBW_TEST_SKIP: "*_arm64"
- uses: actions/upload-artifact@v3
name: wheels
with:
name: wheels
path: ./wheelhouse/*.whl
build_sdist:
name: Build the source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Get GLPK version
id: version
run: |
python -m pip install requests
echo "::set-output name=glpk_version::$(python scripts/find_newest_glpk_release.py)"
- name: Install systems dependencies
run: sudo apt install libgmp-dev swig wget
- name: Download and unpack GLPK
env:
NEW_GLPK_VERSION: ${{ steps.version.outputs.glpk_version }}
run: |
wget "http://ftp.gnu.org/gnu/glpk/glpk-$NEW_GLPK_VERSION.tar.gz"
tar -xf glpk-$NEW_GLPK_VERSION.tar.gz
- name: Build source distribution
env:
NEW_GLPK_VERSION: ${{ steps.version.outputs.glpk_version}}
run: GLPK_HEADER_PATH=glpk-$NEW_GLPK_VERSION/src python setup.py sdist --dist-dir=./wheelhouse
- uses: actions/upload-artifact@v3
name: sdist
with:
name: sdist
path: ./wheelhouse/*.tar.gz
deploy:
name: Release to Github and deploy to PyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Get versions
id: version
run: |
python -m pip install requests
echo "::set-output name=glpk_version::$(python scripts/find_newest_glpk_release.py)"
echo "::set-output name=swigplk_version::$(python scripts/find_swiglpk_version.py)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install twine
- uses: actions/download-artifact@v3
with:
name: wheels
path: wheelhouse
- uses: actions/download-artifact@v3
with:
name: sdist
path: wheelhouse
- name: Publish to PyPI
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run:
twine upload --skip-existing --non-interactive ./wheelhouse/*
- name: Create GitHub release
uses: actions/create-release@v1
if: steps.version.outputs.glpk_version != steps.version.outputs.swigplk_version
env:
# This token is set by gh actions
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body_path: "Release of version ${{ steps.version.glpk_version }}"
draft: false
prerelease: false