Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
9bd31756
Commit
9bd31756
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[scripts][ci] Add pypi deployment
parent
d84f53b5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#25971
passed
6 years ago
Stage: build
Stage: deploy
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitlab-ci.yml
+22
-1
22 additions, 1 deletion
.gitlab-ci.yml
bob/devtools/scripts/ci.py
+68
-1
68 additions, 1 deletion
bob/devtools/scripts/ci.py
conda/meta.yaml
+1
-0
1 addition, 0 deletions
conda/meta.yaml
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
92 additions
and
2 deletions
.gitlab-ci.yml
+
22
−
1
View file @
9bd31756
...
@@ -7,6 +7,7 @@ variables:
...
@@ -7,6 +7,7 @@ variables:
stages
:
stages
:
-
build
-
build
-
deploy
-
deploy
-
pypi
# Build targets
# Build targets
...
@@ -82,7 +83,7 @@ build_macosx_36:
...
@@ -82,7 +83,7 @@ build_macosx_36:
-
build_linux_36
-
build_linux_36
-
build_macosx_36
-
build_macosx_36
tags
:
tags
:
-
d
eploy
er
-
d
ock
er
cache
:
&build_caches
cache
:
&build_caches
paths
:
paths
:
-
miniconda.sh
-
miniconda.sh
...
@@ -104,3 +105,23 @@ deploy_stable:
...
@@ -104,3 +105,23 @@ deploy_stable:
-
/^v\d+\.\d+\.\d+([abc]\d*)?$/
# PEP-440 compliant version (tags)
-
/^v\d+\.\d+\.\d+([abc]\d*)?$/
# PEP-440 compliant version (tags)
except
:
except
:
-
branches
-
branches
pypi
:
stage
:
pypi
environment
:
pypi
only
:
-
/^v\d+\.\d+\.\d+([abc]\d*)?$/
# PEP-440 compliant version (tags)
except
:
-
branches
before_script
:
-
./ci/bootstrap.sh local myenv
script
:
-
source ${CONDA_ROOT}/etc/profile.d/conda.sh
-
conda activate myenv
-
bdt ci pypi -vv
dependencies
:
-
build_linux_36
-
build_macosx_36
tags
:
-
docker
This diff is collapsed.
Click to expand it.
bob/devtools/scripts/ci.py
+
68
−
1
View file @
9bd31756
...
@@ -13,7 +13,7 @@ from click_plugins import with_plugins
...
@@ -13,7 +13,7 @@ from click_plugins import with_plugins
from
.
import
bdt
from
.
import
bdt
from
..log
import
verbosity_option
from
..log
import
verbosity_option
from
..ci
import
is_stable
,
is_visible_outside
from
..ci
import
is_stable
,
is_visible_outside
from
..constants
import
SERVER
,
WEBDAV_PATHS
from
..constants
import
SERVER
,
WEBDAV_PATHS
,
CACERT
from
..webdav3
import
client
as
webdav
from
..webdav3
import
client
as
webdav
...
@@ -134,3 +134,70 @@ def deploy(dry_run):
...
@@ -134,3 +134,70 @@ def deploy(dry_run):
if
not
dry_run
:
if
not
dry_run
:
davclient
.
upload_directory
(
local_path
=
local_docs
,
davclient
.
upload_directory
(
local_path
=
local_docs
,
remote_path
=
remote_path
)
remote_path
=
remote_path
)
@ci.command
(
epilog
=
'''
Examples:
1. Deploys current build artifacts to the Python Package Index (PyPI):
$ bdt ci pypi -vv
'''
)
@click.option
(
'
-d
'
,
'
--dry-run/--no-dry-run
'
,
default
=
False
,
help
=
'
Only goes through the actions, but does not execute them
'
\
'
(combine with the verbosity flags - e.g. ``-vvv``) to enable
'
\
'
printing to help you understand what will be done
'
)
@verbosity_option
()
@bdt.raise_on_error
def
pypi
(
dry_run
):
"""
Deploys build artifacts (python packages to PyPI)
Deployment is only allowed for packages in which the visibility is
"
public
"
. This check prevents publishing of private resources to the
(public) PyPI webserver.
"""
if
dry_run
:
logger
.
warn
(
'
!!!! DRY RUN MODE !!!!
'
)
logger
.
warn
(
'
Nothing is being deployed to server
'
)
package
=
os
.
environ
[
'
CI_PROJECT_PATH
'
]
# determine project visibility
visible
=
is_visible_outside
(
package
,
os
.
environ
[
'
CI_PROJECT_VISIBILITY
'
])
if
not
visible
:
raise
RuntimeError
(
'
The repository %s is not public - a package
'
\
'
deriving from it therefore, CANNOT be published to PyPI.
'
\
'
You must follow the relevant software disclosure procedures
'
\
'
and set this repository to
"
public
"
before trying again.
'
%
package
)
# finds the package that should be published
zip_glob
=
os
.
path
.
join
(
os
.
environ
[
'
CI_PROJECT_DIR
'
],
'
dist
'
,
'
*-*.zip
'
)
zip_files
=
glob
.
glob
(
zip_glob
)
if
len
(
zip_files
)
==
0
:
raise
RuntimeError
(
'
Cannot find .zip files on the
"
dist
"
directory
'
)
if
len
(
zip_files
)
>
1
:
raise
RuntimeError
(
'
There are %d .zip files on the
"
dist
"
directory:
'
\
'
%s - I
\'
m confused on what to publish to PyPI...
'
%
\
(
len
(
zip_files
),
'
,
'
.
join
(
zip_files
)))
logger
.
info
(
'
Deploying python package %s to PyPI
'
,
zip_files
[
0
])
#twine upload --skip-existing --username ${PYPIUSER} --password ${PYPIPASS}
#dist/*.zip
from
twine.settings
import
Settings
settings
=
Settings
(
username
=
os
.
environ
[
'
PYPIUSER
'
],
password
=
os
.
environ
[
'
PYPIPASS
'
],
skip_existing
=
True
,
cacert
=
CACERT
,
)
if
not
dry_run
:
from
twine.commands.upload
import
upload
upload
(
settings
,
zip_files
)
logger
.
info
(
'
Deployment to PyPI successful
'
)
This diff is collapsed.
Click to expand it.
conda/meta.yaml
+
1
−
0
View file @
9bd31756
...
@@ -67,6 +67,7 @@ test:
...
@@ -67,6 +67,7 @@ test:
-
bdt caupdate --help
-
bdt caupdate --help
-
bdt ci --help
-
bdt ci --help
-
bdt ci deploy --help
-
bdt ci deploy --help
-
bdt ci pypi --help
-
sphinx-build -aEW ${PREFIX}/share/doc/{{ name }}/doc {{ project_dir }}/sphinx
-
sphinx-build -aEW ${PREFIX}/share/doc/{{ name }}/doc {{ project_dir }}/sphinx
about
:
about
:
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
9bd31756
...
@@ -57,6 +57,7 @@ setup(
...
@@ -57,6 +57,7 @@ setup(
'
bdt.ci.cli
'
:
[
'
bdt.ci.cli
'
:
[
'
deploy = bob.devtools.scripts.ci:deploy
'
,
'
deploy = bob.devtools.scripts.ci:deploy
'
,
'
pypi = bob.devtools.scripts.ci:pypi
'
,
],
],
},
},
classifiers
=
[
classifiers
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment