Skip to content

Commit e30a897

Browse files
authored
Merge pull request #195 from bjoernricks/master
Autodeployment to pypi
2 parents d0e3a83 + e24608a commit e30a897

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.circleci/config.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,33 @@ commands:
7575
- run:
7676
name: Check with pylint
7777
command: pipenv run pylint --disable=R gvm
78+
deploy:
79+
description: "Upload package to PyPI"
80+
steps:
81+
- checkout
82+
- run:
83+
name: Install dependencies
84+
command: pipenv install
85+
- run:
86+
name: Verify tag version
87+
command: pipenv run python verify-version.py ${CIRCLE_TAG}
88+
- run:
89+
name: Install twine
90+
command: pipenv run pip install twine
91+
- run:
92+
name: Initialize .pypirc
93+
command: |
94+
echo -e "[distutils]" >> ~/.pypirc
95+
echo -e "index-servers = pypi" >> ~/.pypirc
96+
echo -e "[pypi]"
97+
echo -e "username = __token__" >> ~/.pypirc
98+
echo -e "password = $PYPI_TOKEN" >> ~/.pypirc
99+
- run:
100+
name: Create and upload distribution to pypi
101+
command: |
102+
rm -rf dist build python_gvm.egg-info
103+
pipenv run python setup.py sdist bdist_wheel
104+
pipenv run twine upload dist/*
78105
79106
jobs:
80107
build-35:
@@ -105,6 +132,11 @@ jobs:
105132
executor: python-37
106133
steps:
107134
- lint
135+
deploy-37:
136+
executor: python-37
137+
steps:
138+
- deploy
139+
108140

109141
workflows:
110142
version: 2
@@ -117,3 +149,19 @@ workflows:
117149
- build-37
118150
- test-37
119151
- lint-37
152+
build_and_deploy:
153+
jobs:
154+
- build-37:
155+
filters:
156+
tags:
157+
only: /.*/
158+
branches:
159+
ignore: /.*/
160+
- deploy-37:
161+
requires:
162+
- build-37
163+
filters:
164+
tags:
165+
only: /.*/
166+
branches:
167+
ignore: /.*/

verify-version.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright (C) 2020 Greenbone Networks GmbH
3+
#
4+
# SPDX-License-Identifier: GPL-3.0-or-later
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
import sys
20+
21+
from gvm import get_version
22+
23+
24+
def main():
25+
if len(sys.argv) < 2:
26+
sys.exit('Missing argument for version.')
27+
return
28+
29+
p_version = sys.argv[1]
30+
version = get_version()
31+
if p_version != version:
32+
sys.exit(
33+
"Provided version: {} does not match the python-gvm "
34+
"version: {}".format(p_version, version)
35+
)
36+
37+
38+
if __name__ == '__main__':
39+
main()

0 commit comments

Comments
 (0)