Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gajim
python-nbxmpp
Commits
0d0bb0fa
Commit
0d0bb0fa
authored
Jan 18, 2023
by
Philipp Hörist
Browse files
ci: Use release-helper
- Remove obsolete scripts
parent
510072da
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.ci/debian_build.py
deleted
100644 → 0
View file @
510072da
#!/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
)
.ci/deploy.py
deleted
100755 → 0
View file @
510072da
#!/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
()
.gitlab-ci.yml
View file @
0d0bb0fa
...
...
@@ -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/*
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment