forked from Project-MONAI/MONAI
-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (156 loc) · 5.18 KB
/
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
name: release
# generating and testing package artefacts from the main branch
on:
push:
branches:
- main
tags:
- '*'
jobs:
packaging:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install setuptools
run: |
python -m pip install --user --upgrade setuptools wheel
- name: Build and test source archive and wheel file
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
root_dir=$PWD
echo "$root_dir"
set -e
# build tar.gz and wheel
python setup.py sdist bdist_wheel --build-number $(date +'%Y%m%d%H%M')
tmp_dir=$(mktemp -d)
cp dist/monai* "$tmp_dir"
cd "$tmp_dir"
ls -al
# install from tar.gz
python -m pip install monai*.tar.gz
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
python -m pip uninstall -y monai
rm monai*.tar.gz
# install from wheel
python -m pip install monai*.whl
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
# clean up
cd "$root_dir"
rm -r "$tmp_dir"
rm -rf monai/
ls -al .
- name: Quick test installed
run: |
python -m pip install -r requirements-min.txt
python -m tests.min_tests
env:
QUICKTEST: True
- if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/')
name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
- if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/')
name: Check artifacts
run: |
ls -al dist/
rm dist/monai*.tar.gz
ls -al dist/
- if: matrix.python-version == '3.9' && startsWith(github.ref, 'refs/tags/')
name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI }}
repository-url: https://test.pypi.org/legacy/
versioning:
# compute versioning file from python setup.py
# upload as artifact
if: github.repository == 'Project-MONAI/MONAI'
needs: packaging
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# full history so that we can git describe
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: '3.9'
- shell: bash
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
git describe
python -m pip install --user --upgrade setuptools wheel
python setup.py build
cat build/lib/monai/_version.py
- name: Upload version
uses: actions/upload-artifact@v4
with:
name: _version.py
path: build/lib/monai/_version.py
- name: Clean up directory
shell: bash
run: |
ls -al
rm -rf {*,.[^.]*}
release_tag_docker:
# if: github.repository == 'Project-MONAI/MONAI'
if: ${{ false }}
needs: versioning
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download version
uses: actions/download-artifact@v4
with:
name: _version.py
- name: Set tag
id: versioning
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Check tag
env:
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
run: |
echo "$RELEASE_VERSION"
cat _version.py
- if: startsWith(github.ref, 'refs/tags/')
name: build with the tag
env:
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
shell: bash
run: |
find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \;
# get tag info for versioning
mv _version.py monai/
# version checks
target=" \"version\": \"$RELEASE_VERSION\""
local=`grep "\"version\"" monai/_version.py`
echo "$target"
echo "$local"
if [[ "$local" == "$target" ]]; then
echo "matched version string"
else
echo "unmatched version string, please check the tagging branch."
exit 1
fi
# remove flake package as it is not needed on hub.docker.com
sed -i '/flake/d' requirements-dev.txt
docker build -t projectmonai/monai:"$RELEASE_VERSION" -f Dockerfile .
# distribute with a tag to hub.docker.com
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
docker push projectmonai/monai:"$RELEASE_VERSION"
docker logout