Skip to content

Commit 9fa9d6c

Browse files
Switch deploy configuration methods (#794)
* ci(gha): change deploy configs to test pypa publish gha * chore(setup.py): upload readme correctly * ci(deploy): update deploy config for production
1 parent e151e82 commit 9fa9d6c

File tree

6 files changed

+27
-62
lines changed

6 files changed

+27
-62
lines changed

.bumpversion.cfg

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ commit = True
66
search = __version__ = '{current_version}'
77
replace = __version__ = '{new_version}'
88

9-
[bumpversion:file:setup.cfg]
10-
search = version = '{current_version}'
11-
replace = version = '{new_version}'
9+
[bumpversion:file:setup.py]
10+
search = __version__ = '{current_version}'
11+
replace = __version__ = '{new_version}'

.github/workflows/deploy.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
npm install -g @semantic-release/github
4444
npm install -g @semantic-release/commit-analyzer
4545
npm install -g @semantic-release/release-notes-generator
46-
npm install -g semantic-release-pypi
47-
pip3 install setuptools wheel twine
4846
- name: Publish js docs
4947
if: ${{ github.event.workflow_run.conclusion == 'success' }}
5048
env:
@@ -59,7 +57,13 @@ jobs:
5957
env:
6058
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
6159
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
6360
run: npx semantic-release #--dry-run --branches 9388_gha Uncomment for testxing purposes
6461
- name: Build binary wheel and a source tarball
65-
run: python setup.py sdist
62+
run: |
63+
pip3 install setuptools wheel twine build
64+
python -m build --sdist --outdir dist/
65+
- name: Publish distribution to Test PyPI
66+
uses: pypa/gh-action-pypi-publish@v1.4.2 # Try to update version tag every release
67+
with:
68+
password: ${{ secrets.PYPI_TOKEN }}
69+
repository_url: https://upload.pypi.org/legacy/ # This must be changed if testing deploys to test.pypi.org

.releaserc

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
"message": "chore(release): ${nextRelease.version} release notes\n\n${nextRelease.notes}"
1717
}
1818
],
19-
[
20-
"semantic-release-pypi",
21-
{
22-
"repoUrl": "https://upload.pypi.org/legacy"
23-
}
24-
],
2519
"@semantic-release/github"
2620
]
2721
}

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel"]
3+
build-backend = "setuptools.build_meta"

setup.cfg

-2
This file was deleted.

setup.py

+13-47
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,27 @@
1414
# limitations under the License.
1515

1616
from setuptools import setup
17-
from setuptools.command.test import test as TestCommand
18-
import os
19-
import sys
17+
from os import path
2018

19+
__version__ = '5.2.0'
2120

22-
if sys.argv[-1] == 'publish':
23-
# test server
24-
os.system('python setup.py register -r pypitest')
25-
os.system('python setup.py sdist upload -r pypitest')
26-
27-
# production server
28-
os.system('python setup.py register -r pypi')
29-
os.system('python setup.py sdist upload -r pypi')
30-
sys.exit()
31-
32-
# Convert README.md to README.rst for pypi
33-
try:
34-
from pypandoc import convert_file
35-
36-
def read_md(f):
37-
return convert_file(f, 'rst')
38-
39-
# read_md = lambda f: convert(f, 'rst')
40-
except:
41-
print('warning: pypandoc module not found, '
42-
'could not convert Markdown to RST')
43-
44-
def read_md(f):
45-
return open(f, 'rb').read().decode(encoding='utf-8')
46-
# read_md = lambda f: open(f, 'rb').read().decode(encoding='utf-8')
47-
48-
49-
class PyTest(TestCommand):
50-
def finalize_options(self):
51-
TestCommand.finalize_options(self)
52-
self.test_args = ['--strict', '--verbose', '--tb=long', 'test']
53-
self.test_suite = True
54-
55-
def run_tests(self):
56-
import pytest
57-
errcode = pytest.main(self.test_args)
58-
sys.exit(errcode)
59-
21+
# read contents of README file
22+
this_directory = path.abspath(path.dirname(__file__))
23+
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as file:
24+
readme_file = file.read()
6025

6126
setup(name='ibm-watson',
27+
version=__version__,
6228
description='Client library to use the IBM Watson Services',
29+
packages=['ibm_watson'],
30+
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==1.1.0', 'ibm_cloud_sdk_core>=3.3.6, == 3.*'],
31+
tests_require=['responses', 'pytest', 'python_dotenv', 'pytest-rerunfailures'],
6332
license='Apache 2.0',
64-
install_requires=['requests>=2.0, <3.0', 'python_dateutil>=2.5.3', 'websocket-client==0.48.0', 'ibm_cloud_sdk_core>=3.3.6, == 3.*'],
65-
tests_require=['responses', 'pytest', 'python_dotenv', 'pytest-rerunfailures', 'tox'],
66-
cmdclass={'test': PyTest},
6733
author='IBM Watson',
6834
author_email='watdevex@us.ibm.com',
69-
long_description=read_md('README.md'),
35+
long_description=readme_file,
36+
long_description_content_type='text/markdown',
7037
url='https://github.com/watson-developer-cloud/python-sdk',
71-
packages=['ibm_watson'],
7238
include_package_data=True,
7339
keywords='language, vision, question and answer' +
7440
' tone_analyzer, natural language classifier,' +
@@ -81,7 +47,7 @@ def run_tests(self):
8147
'Programming Language :: Python',
8248
'Programming Language :: Python :: 2',
8349
'Programming Language :: Python :: 3',
84-
'Development Status :: 4 - Beta',
50+
'Development Status :: 5 - Production/Stable',
8551
'Intended Audience :: Developers',
8652
'License :: OSI Approved :: Apache Software License',
8753
'Operating System :: OS Independent',

0 commit comments

Comments
 (0)