-
Notifications
You must be signed in to change notification settings - Fork 725
128 lines (126 loc) · 4.11 KB
/
publish-package.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
name: Build and publish the package to PyPI
on:
workflow_dispatch:
inputs:
publish:
description: 'Whether to publish the package (as opposed to just building it)'
required: false
default: true
type: boolean
repository:
description: 'Whether to publish to production PyPI or test PyPI'
required: false
default: pypi
type: choice
options: [pypi, testpypi]
ref:
description: 'The git ref to build the package for'
required: false
default: ''
type: string
use_lkg:
description: 'Whether to use the last known good versions of dependencies'
required: false
default: True
type: boolean
# annoyingly, there does not seem to be a way to share these input definitions between triggers
workflow_call:
inputs:
publish:
description: 'Whether to publish the package (as opposed to just building it)'
required: false
default: true
type: boolean
# choice type only supported for workflow_dispatch, not workflow_call
repository:
description: 'Whether to publish to production PyPI or test PyPI'
required: false
default: pypi
type: string
ref:
description: 'The git ref to build the package for'
required: false
default: ''
type: string
use_lkg:
description: 'Whether to use the last known good versions of dependencies'
required: false
default: True
type: boolean
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: Checkout repository
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-python@v5
name: Setup Python
with:
python-version: 3.9
- run: python -m pip install --upgrade pip && pip install --upgrade setuptools
name: Ensure latest pip and setuptools
- run: pip install cibuildwheel && python -m cibuildwheel --output-dir dist
name: Build wheels
env:
CIBW_BUILD: cp3*
CIBW_SKIP: "*musl* *win32 *i686"
- uses: actions/upload-artifact@v3
name: Upload wheels as artifact
with:
name: dist
path: dist/
build_sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout repository
with:
ref: ${{ inputs.ref }}
- uses: actions/setup-python@v5
name: Setup Python
with:
python-version: 3.8 # because of our supported TensorFlow versions, must build on 3.6-3.8
- run: python -m pip install --upgrade pip && pip install --upgrade setuptools
name: Ensure latest pip and setuptools
- run: pip install -e .[all] ${{ inputs.use_lkg && '-r lkg.txt' || '' }}
name: Install econml[all]
- run: python setup.py sdist
name: Build sdist
- uses: actions/upload-artifact@v3
name: Upload sdist as artifact
with:
name: dist
path: dist/
publish:
name: Publish to PyPI or TestPyPI
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v5
name: Setup Python
with:
python-version: 3.9
- run: python -m pip install --upgrade pip && pip install --upgrade setuptools
name: Ensure latest pip and setuptools
- run: pip install twine
name: Install twine
- uses: actions/download-artifact@v3
name: Download wheels and sdist
with:
name: dist
path: dist/
- run: twine upload dist/*
name: Upload wheels and sdist to package index
env:
TWINE_USERNAME: __token__
TWINE_REPOSITORY: ${{ inputs.repository }}
TWINE_PASSWORD: ${{ inputs.repository == 'pypi' && secrets.PYPI_UPLOAD_TOKEN || secrets.TEST_PYPI_UPLOAD_TOKEN }}
if: ${{ inputs.publish }}