-
Notifications
You must be signed in to change notification settings - Fork 10
176 lines (160 loc) · 5.78 KB
/
build-and-release.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
name: Build and Release Conda
on:
push:
branches: [ master ]
pull_request:
create:
tags:
- v*
workflow_dispatch:
env:
conda_version: 4.12.0
conda_build_version: 3.21.8
jobs:
set-anaconda-tag:
runs-on: ubuntu-latest
outputs:
anaconda-tag: ${{ steps.anaconda-tag.outputs.tag }}
steps:
- name: Set Tag for Anaconda
id: anaconda-tag
run:
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "tag=dev" >> $GITHUB_OUTPUT;
elif [[ $GITHUB_REF =~ refs/tags/* ]]; then
echo "tag=main" >> $GITHUB_OUTPUT;
fi
build-windows:
strategy:
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: Add Conda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python_version }}
- name: Add scripts path
run: echo "$env:CONDA\Scripts" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Updating conda-build...
shell: cmd
run: |
# on Windows conda is a bat file that will exit it not "CALL"'d
# https://docs.conda.io/projects/conda/en/latest/user-guide/troubleshooting.html#using-conda-in-windows-batch-script-exits-early
call activate
call conda update --yes conda
call conda install --yes conda-build
call conda create --yes --quiet --name bld --no-default-packages
call conda install --yes --name bld conda-build=${{ env.conda_build_version }}
- name: Building...
shell: cmd
run: |
call activate bld
call conda build --no-build-id --python "${{ matrix.python_version }}" --output-folder channel recipe
- name: Publishing artifact...
uses: actions/upload-artifact@v3
with:
path: "channel/*/simpleitk*.tar.bz2"
build-linux:
strategy:
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Add conda to PATH
shell: bash
run: echo "$CONDA/bin" >> $GITHUB_PATH
- name: "Creating updated environment with conda-build..."
shell: bash
run: |
source activate
conda update --yes conda
conda create --yes --quiet --name bld --no-default-packages
conda install --yes --name bld conda-build
- name: "Building conda package..."
shell: bash
run: |
set -x
source activate bld
conda build --python ${{ matrix.python_version }} --output-folder channel recipe
- uses: actions/upload-artifact@v3
with:
path: "${{github.workspace}}/channel/*/simpleitk*.tar.bz2"
build-mac:
strategy:
matrix:
python_version: ['3.7', '3.8', '3.9', '3.10']
env:
MACOSX_SDK: '10.10'
MACOSX_DEPLOYMENT_TARGET: '10.9'
runs-on: macos-11
steps:
- uses: actions/checkout@v3
name: Checkout
- name: Take ownership of conda installation
run: sudo chown -R $USER $CONDA
shell: bash
- name: Add conda to PATH
shell: bash
run: echo "$CONDA/bin" >> $GITHUB_PATH
- name: "Creating updated environment with conda-build..."
shell: bash
run: |
set -x
sudo xcode-select --switch /Applications/Xcode_11.7.0.app
xcode-select -p
# https://docs.conda.io/projects/conda-build/en/latest/resources/compiler-tools.html?highlight=CONDA_BUILD_SYSROOT#macos-sdk
echo "Downloading ${MACOSX_SDK} sdk"
curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/10.15/MacOSX${MACOSX_SDK}.sdk.tar.xz
tar -xf MacOSX${MACOSX_SDK}.sdk.tar.xz -C "$(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs"
# path autoloaded: https://docs.conda.io/projects/conda-build/en/latest/resources/variants.html#creating-conda-build-variant-config-files
cat << EOF >> ~/conda_build_config.yml
CONDA_BUILD_SYSROOT:
- $(xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${MACOSX_SDK}.sdk
MACOSX_DEPLOYMENT_TARGET:
- ${MACOSX_DEPLOYMENT_TARGET}
EOF
source activate
conda update --yes conda
conda create --yes --quiet --name bld --no-default-packages
conda install --yes --name bld conda-build
- name: "Building conda package..."
shell: bash
run: |
export PYTHONUNBUFFERED=1
set -x
source activate bld
conda build --python ${{ matrix.python_version }} --output-folder channel recipe
- uses: actions/upload-artifact@v3
with:
path: "${{github.workspace}}/channel/*/simpleitk*.tar.bz2"
publish:
environment:
name: release
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' }}
needs: [build-windows, build-linux, build-mac, set-anaconda-tag]
steps:
- uses: actions/[email protected]
- name: Verify files
run: ls -LR
- name: Add conda to PATH
shell: bash
run: echo "$CONDA/bin" >> $GITHUB_PATH
- name: "Creating updated environment with conda-build..."
shell: bash
run: |
source activate
conda update --yes conda
conda install --yes anaconda-client
- name: Sign into anaconda and upload
run: |
anaconda upload --force --no-progress --user ${ANACONDA_ORGANIZATION} --label ${ANACONDA_LABEL} ./artifact/*/*.tar.bz2
env:
ANACONDA_ORGANIZATION: simpleitk
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
ANACONDA_LABEL: ${{needs.set-anaconda-tag.outputs.anaconda-tag}}