This repository has been archived by the owner on Dec 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
156 lines (132 loc) · 4.61 KB
/
deploy.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
name: Deployment
on:
# this workflow can only be manually triggered for now.
workflow_dispatch:
inputs:
deploy:
description: 'Where to deploy the artifacts? Only build (build), deploy to test PyPI (test), or deploy to PyPI (prod).'
required: true
type: choice
default: 'test'
options:
- build
- test
- prod
env:
PYTHONUNBUFFERED: 1
PYTEST_ADDOPTS: "--color=yes"
jobs:
build-windows-wheel-and-sdist:
# do not run on forked repo
if: github.repository == 'facebookresearch/beanmachine'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
python-version: ['3.9', '3.10']
include:
- python-version: '3.9' # source distribution only needs to be build once
os: ubuntu-latest
defaults:
run:
# https://github.com/conda-incubator/setup-miniconda/tree/v2#use-a-default-shell
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Miniconda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
activate-environment: build_env
- name: Install other dependencies
run: |
conda install -c conda-forge -y boost-cpp eigen range-v3
python -m pip install --upgrade pip
pip install -U build
- name: Building Bean Machine wheel on ${{ matrix.os }} ${{ matrix.python-version }}
if: matrix.os == 'windows-latest'
run: python -m build --wheel
- name: Building source distribution on ${{ matrix.os }}
if: matrix.os == 'ubuntu-latest'
run: python -m build --sdist
- name: Install built Bean Machine
# this will install prebuilt wheels on Windows or sdist on Ubuntu
run: pip install dist/*
- name: Install pytest
run: pip install -U pytest
- name: Print out package info to help with debug
run: pip list
- name: Run unit tests with pytest
run: pytest
- name: Sending wheels to the deployment workflow
uses: actions/upload-artifact@v3
with:
name: beanmachine-wheels
path: dist/*
cibuildwheel:
if: github.repository == 'facebookresearch/beanmachine'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
cibw_build: ['cp39-*', 'cp310-*']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Boost and Eigen dependencies (MacOS only)
if: matrix.os == 'macos-latest'
run: brew install boost eigen range-v3
- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_BUILD: ${{ matrix.cibw_build }}
CIBW_SKIP: "*-manylinux_i686 *-musllinux_*"
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_BEFORE_ALL_LINUX: > # Manually install Eigen3.4 since yum is not up to date
yum install -y curl zip unzip tar wget boost169-devel range-v3-devel &&
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz &&
tar -xvf eigen-3.4.0.tar.gz &&
mv eigen-3.4.0 /usr/include/eigen3
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: pytest {package}
MACOSX_DEPLOYMENT_TARGET: "10.13"
- name: Sending wheels to the deployment workflow
uses: actions/upload-artifact@v3
with:
name: beanmachine-wheels
path: wheelhouse/*
publish-to-pypi:
runs-on: ubuntu-latest
needs:
- build-windows-wheel-and-sdist
- cibuildwheel
steps:
- name: Download wheels from previous jobs
# by default this will download all artifacts
uses: actions/download-artifact@v3
with:
name: beanmachine-wheels
# PyPI publish action uploads everything under dist/* by default
path: dist
- name: Display the list of artifacts
run: ls -R dist
- name: Publish to Test PyPI
if: github.event.inputs.deploy == 'test'
uses: pypa/[email protected]
with:
password: ${{ secrets.TEST_PYPI_PASSWORD }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
verbose: true
- name: Publish to PyPI
if: github.event.inputs.deploy == 'prod' && startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_PASSWORD }}
verbose: true