Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-01-18 23:42:52 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-01-18 23:57:24 +0300
commit0d0bb0fa6abfcec9f56f0fdf36ca53232015f61a (patch)
treee90c6baac0cb2b54e97ed066c716845012b21dc1
parent510072da587e0e374296267bde38d63e28ed18d4 (diff)
ci: Use release-helper
- Remove obsolete scripts
-rw-r--r--.ci/debian_build.py105
-rwxr-xr-x.ci/deploy.py45
-rw-r--r--.gitlab-ci.yml5
3 files changed, 4 insertions, 151 deletions
diff --git a/.ci/debian_build.py b/.ci/debian_build.py
deleted file mode 100644
index 7c2fc35..0000000
--- a/.ci/debian_build.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/env python3
-
-from __future__ import annotations
-
-import argparse
-import dataclasses
-import logging
-import shutil
-import subprocess
-from datetime import datetime
-from datetime import timezone
-from pathlib import Path
-
-LOG_FORMAT = '%(asctime)s %(levelname)s %(message)s'
-logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)
-log = logging.getLogger()
-
-ROOT_DIR = Path(__file__).resolve().parent.parent
-BUILD_DIR = ROOT_DIR / 'debian_build'
-
-DATE = datetime.now().strftime('%Y%m%d')
-DATE_TIME = datetime.now(tz=timezone.utc).strftime('%a, %d %b %Y %T %z')
-
-
-@dataclasses.dataclass
-class ReleaseContext:
- app: str
- pkg_name: str
- rev: str
- release_name: str
- release_dir: Path
- tarball: Path
-
- @classmethod
- def from_tarball(cls, path: str, prefix: str, rev: str) -> ReleaseContext:
- tarball = Path(path)
- app = tarball.name.split('-', maxsplit=1)[0]
- pkg_name = f'{prefix}{app}-nightly'
- release_name = f'{pkg_name}_{DATE}'
- release_dir = BUILD_DIR / release_name
- return cls(app=app,
- pkg_name=pkg_name,
- rev=rev,
- release_name=release_name,
- release_dir=release_dir,
- tarball=tarball)
-
-
-def clean_build_dir() -> None:
- log.info('Cleanup build directory')
- if BUILD_DIR.exists():
- shutil.rmtree(BUILD_DIR)
- BUILD_DIR.mkdir()
-
-
-def prepare_package_dir(context: ReleaseContext) -> None:
- log.info('Extract tarball')
- tarball = Path(shutil.copy(context.tarball, BUILD_DIR))
- tarball = tarball.rename(BUILD_DIR / f'{context.release_name}.orig.tar.gz')
- shutil.unpack_archive(tarball, BUILD_DIR)
-
- log.info('Rename dir to: %s', context.release_name)
- folder = list(BUILD_DIR.glob(f'{context.app}-?.?.?'))[0]
- folder = folder.rename(context.release_dir)
-
- log.info('Copy debian folder into release directory')
- shutil.copytree(ROOT_DIR / 'debian', context.release_dir / 'debian')
-
-
-def prepare_changelog(context: ReleaseContext) -> None:
- log.info('Prepare Changelog')
- changelog = context.release_dir / 'debian' / 'changelog'
- content = changelog.read_text()
- content = content.replace('{DATE}', f'{DATE}-{context.rev}')
- content = content.replace('{DATE_TIME}', DATE_TIME)
- changelog.write_text(content)
-
-
-def build(context: ReleaseContext) -> None:
- log.info('Start package build')
- subprocess.run(
- [
- 'dpkg-buildpackage',
- '--no-sign'
- ],
- cwd=context.release_dir,
- check=True)
-
-
-if __name__ == '__main__':
- parser = argparse.ArgumentParser(description='Build debian package')
- parser.add_argument('tarball', help='Path to tarball e.g. app.tar.gz')
- parser.add_argument('rev', help='The package revision e.g. 1')
- parser.add_argument('--pkgprefix', default='', required=False,
- help='Prefix for the package name e.g. python3-')
- args = parser.parse_args()
-
- context = ReleaseContext.from_tarball(args.tarball,
- args.pkgprefix,
- args.rev)
-
- clean_build_dir()
- prepare_package_dir(context)
- prepare_changelog(context)
- build(context)
diff --git a/.ci/deploy.py b/.ci/deploy.py
deleted file mode 100755
index 89cc163..0000000
--- a/.ci/deploy.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python3
-
-import os
-import sys
-import subprocess
-from pathlib import Path
-
-
-REPO_DIR = Path(__file__).parent.parent
-USERNAME = '__token__'
-PASSWORD = os.environ['PYPI_TOKEN']
-
-
-def build() -> None:
- cmd = [
- 'python3',
- 'setup.py',
- 'sdist',
- 'bdist_wheel'
- ]
-
- try:
- subprocess.run(cmd, cwd=REPO_DIR, check=True)
- except subprocess.CalledProcessError:
- sys.exit('build failed')
-
-
-def upload() -> None:
- cmd = [
- 'twine',
- 'upload',
- '--username', USERNAME,
- '--password', PASSWORD,
- 'dist/*'
- ]
-
- try:
- subprocess.run(cmd, cwd=REPO_DIR, check=True)
- except subprocess.CalledProcessError:
- sys.exit('upload failed')
-
-
-if __name__ == '__main__':
- # build()
- upload()
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 426066e..e34b056 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,9 +24,10 @@ build-linux:
stage: build
dependencies: []
script:
+ - pip install git+https://dev.gajim.org/gajim/release-helper.git
- pip install build
- python3 -m build
- - python3 .ci/debian_build.py "$(find dist/nbxmpp-*.tar.gz)" 1 --pkgprefix=python3-
+ - release-helper build-debian-pkg "$(find dist/nbxmpp-*.tar.gz)" 1 --pkgprefix=python3 --pkgsuffix=nightly
artifacts:
name: "nbxmpp-$CI_COMMIT_SHA"
@@ -34,6 +35,7 @@ build-linux:
paths:
- dist/nbxmpp-*.tar.gz
- dist/nbxmpp-*.whl
+ - debian_build/python3-nbxmpp*.deb
deploy-pypi:
stage: deploy
@@ -43,3 +45,4 @@ deploy-pypi:
- if: '$CI_COMMIT_TAG'
script:
- python3 .ci/deploy.py
+ - twine upload --username=__token__ --password=$PYPI_TOKEN dist/*