Skip to content

Commit 501026b

Browse files
authored
pipeline for releasing the docker images (#1953)
* adds docker tag action Signed-off-by: Wenqi Li <wenqil@nvidia.com> * adds tag info Signed-off-by: Wenqi Li <wenqil@nvidia.com> * update versioneer Signed-off-by: Wenqi Li <wenqil@nvidia.com>
1 parent fbce3c2 commit 501026b

File tree

4 files changed

+146
-77
lines changed

4 files changed

+146
-77
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,32 @@ jobs:
8383
password: ${{ secrets.TEST_PYPI }}
8484
repository_url: https://test.pypi.org/legacy/
8585

86+
release_docker:
87+
if: github.repository == 'Project-MONAI/MONAI'
88+
needs: packaging
89+
runs-on: [ self-hosted, linux, x64, build_only ]
90+
steps:
91+
- uses: actions/checkout@v2
92+
with:
93+
ref: master
94+
- name: Set tag
95+
id: versioning
96+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
97+
- name: Check tag
98+
env:
99+
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
100+
run: |
101+
echo "$RELEASE_VERSION"
102+
- if: startsWith(github.ref, 'refs/tags/')
103+
name: build with the tag
104+
env:
105+
RELEASE_VERSION: ${{ steps.versioning.outputs.tag }}
106+
run: |
107+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
108+
# remove flake package as it is not needed on hub.docker.com
109+
sed -i '/flake/d' requirements-dev.txt
110+
docker build -t projectmonai/monai:"$RELEASE_VERSION" -f Dockerfile .
111+
# distribute with a tag to hub.docker.com
112+
echo "${{ secrets.DOCKER_PW }}" | docker login -u projectmonai --password-stdin
113+
docker push projectmonai/monai:"$RELEASE_VERSION"
114+
docker logout

.github/workflows/setupapp.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ jobs:
159159
ref: master
160160
- name: docker_build
161161
run: |
162+
# get tag info for versioning
163+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
162164
# build and run original docker image for local registry
163165
docker build -t localhost:5000/local_monai:latest -f Dockerfile .
164166
docker push localhost:5000/local_monai:latest

monai/_version.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
12
# This file helps to compute a version number in source trees obtained from
23
# git-archive tarball (such as those provided by githubs download-from-tag
34
# feature). Distribution tarballs (built by setup.py sdist) and build
45
# directories (produced by setup.py build) will contain a much shorter file
56
# that just contains the computed version number.
67

78
# This file is released into the public domain. Generated by
8-
# versioneer-0.18 (https://github.com/warner/python-versioneer)
9+
# versioneer-0.19 (https://github.com/python-versioneer/python-versioneer)
910

1011
"""Git implementation of _version.py."""
1112

@@ -56,7 +57,7 @@ class NotThisMethod(Exception):
5657

5758

5859
def register_vcs_handler(vcs, method): # decorator
59-
"""Decorator to mark a method as the handler for a particular VCS."""
60+
"""Create decorator to mark a method as the handler of a VCS."""
6061
def decorate(f):
6162
"""Store f in HANDLERS[vcs][method]."""
6263
if vcs not in HANDLERS:
@@ -92,9 +93,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
9293
if verbose:
9394
print("unable to find command, tried %s" % (commands,))
9495
return None, None
95-
stdout = p.communicate()[0].strip()
96-
if sys.version_info[0] >= 3:
97-
stdout = stdout.decode()
96+
stdout = p.communicate()[0].strip().decode()
9897
if p.returncode != 0:
9998
if verbose:
10099
print("unable to run %s (error)" % dispcmd)
@@ -164,6 +163,10 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
164163
raise NotThisMethod("no keywords at all, weird")
165164
date = keywords.get("date")
166165
if date is not None:
166+
# Use only the last line. Previous lines may contain GPG signature
167+
# information.
168+
date = date.splitlines()[-1]
169+
167170
# git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
168171
# datestamp. However we prefer "%ci" (which expands to an "ISO-8601
169172
# -like" string, which we must then edit to make compliant), because
@@ -299,6 +302,9 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
299302
# commit date: see ISO-8601 comment in git_versions_from_keywords()
300303
date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"],
301304
cwd=root)[0].strip()
305+
# Use only the last line. Previous lines may contain GPG signature
306+
# information.
307+
date = date.splitlines()[-1]
302308
pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
303309

304310
return pieces
@@ -337,18 +343,18 @@ def render_pep440(pieces):
337343

338344

339345
def render_pep440_pre(pieces):
340-
"""TAG[.post.devDISTANCE] -- No -dirty.
346+
"""TAG[.post0.devDISTANCE] -- No -dirty.
341347
342348
Exceptions:
343-
1: no tags. 0.post.devDISTANCE
349+
1: no tags. 0.post0.devDISTANCE
344350
"""
345351
if pieces["closest-tag"]:
346352
rendered = pieces["closest-tag"]
347353
if pieces["distance"]:
348-
rendered += ".post.dev%d" % pieces["distance"]
354+
rendered += ".post0.dev%d" % pieces["distance"]
349355
else:
350356
# exception #1
351-
rendered = "0.post.dev%d" % pieces["distance"]
357+
rendered = "0.post0.dev%d" % pieces["distance"]
352358
return rendered
353359

354360

@@ -494,7 +500,7 @@ def get_versions():
494500
# versionfile_source is the relative path from the top of the source
495501
# tree (where the .git directory might live) to this file. Invert
496502
# this to find the root from __file__.
497-
for i in cfg.versionfile_source.split('/'): # lgtm[py/unused-loop-variable]
503+
for i in cfg.versionfile_source.split('/'):
498504
root = os.path.dirname(root)
499505
except NameError:
500506
return {"version": "0+unknown", "full-revisionid": None,

0 commit comments

Comments
 (0)