Merge pull request #96 from kiwix/make_release

Make release
This commit is contained in:
Matthieu Gautier 2017-12-05 10:20:41 +00:00 committed by GitHub
commit 29157c96eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 125 additions and 33 deletions

View File

@ -135,6 +135,8 @@ class CTPP2(Dependency):
version = "2.8.3" version = "2.8.3"
class Source(ReleaseDownload): class Source(ReleaseDownload):
name = "ctpp2"
source_dir = "ctpp2-2.8.3"
archive = Remotefile('ctpp2-2.8.3.tar.gz', archive = Remotefile('ctpp2-2.8.3.tar.gz',
'a83ffd07817adb575295ef40fbf759892512e5a63059c520f9062d9ab8fb42fc') 'a83ffd07817adb575295ef40fbf759892512e5a63059c520f9062d9ab8fb42fc')
patches = ["ctpp2_include.patch", patches = ["ctpp2_include.patch",
@ -276,9 +278,11 @@ class Libzim(Dependency):
class Source(GitClone): class Source(GitClone):
git_remote = "https://github.com/openzim/libzim.git" git_remote = "https://github.com/openzim/libzim.git"
git_dir = "libzim" git_dir = "libzim"
release_git_ref = "3.0.0"
Builder = MesonBuilder Builder = MesonBuilder
class ZimTools(Dependency): class ZimTools(Dependency):
name = "zim-tools" name = "zim-tools"
dependencies = ['libzim'] dependencies = ['libzim']
@ -336,6 +340,7 @@ class Kiwixlib(Dependency):
class Source(GitClone): class Source(GitClone):
git_remote = "https://github.com/kiwix/kiwix-lib.git" git_remote = "https://github.com/kiwix/kiwix-lib.git"
git_dir = "kiwix-lib" git_dir = "kiwix-lib"
release_git_ref = "1.0.1"
class Builder(MesonBuilder): class Builder(MesonBuilder):
@property @property
@ -359,6 +364,7 @@ class KiwixTools(Dependency):
class Source(GitClone): class Source(GitClone):
git_remote = "https://github.com/kiwix/kiwix-tools.git" git_remote = "https://github.com/kiwix/kiwix-tools.git"
git_dir = "kiwix-tools" git_dir = "kiwix-tools"
release_git_ref = "0.3.0"
class Builder(MesonBuilder): class Builder(MesonBuilder):
@property @property

View File

@ -123,22 +123,33 @@ class ReleaseDownload(Source):
class GitClone(Source): class GitClone(Source):
git_ref = "master" base_git_ref = "master"
release_git_ref = "master"
@property @property
def source_dir(self): def source_dir(self):
if self.buildEnv.make_release:
return "{}_release".format(self.git_dir)
else:
return self.git_dir return self.git_dir
@property @property
def git_path(self): def git_path(self):
return pj(self.buildEnv.source_dir, self.git_dir) return pj(self.buildEnv.source_dir, self.source_dir)
@property
def git_ref(self):
if self.buildEnv.make_release:
return self.release_git_ref
else:
return self.base_git_ref
def _git_clone(self, context): def _git_clone(self, context):
context.force_native_build = True context.force_native_build = True
if os.path.exists(self.git_path): if os.path.exists(self.git_path):
raise SkipCommand() raise SkipCommand()
command = "git clone --depth=1 --branch {} {} {}".format( command = "git clone --depth=1 --branch {} {} {}".format(
self.git_ref, self.git_remote, self.git_dir) self.git_ref, self.git_remote, self.source_dir)
self.buildEnv.run_command(command, self.buildEnv.source_dir, context) self.buildEnv.run_command(command, self.buildEnv.source_dir, context)
def _git_update(self, context): def _git_update(self, context):
@ -218,6 +229,12 @@ class Builder:
if hasattr(self, '_post_build_script'): if hasattr(self, '_post_build_script'):
self.command('post_build_script', self._post_build_script) self.command('post_build_script', self._post_build_script)
def make_dist(self):
if hasattr(self, '_pre_build_script'):
self.command('pre_build_script', self._pre_build_script)
self.command('configure', self._configure)
self.command('make_dist', self._make_dist)
class MakeBuilder(Builder): class MakeBuilder(Builder):
configure_option = "" configure_option = ""
@ -274,6 +291,11 @@ class MakeBuilder(Builder):
) )
self.buildEnv.run_command(command, self.build_path, context) self.buildEnv.run_command(command, self.build_path, context)
def _make_dist(self, context):
context.try_skip(self.build_path)
command = "make dist"
self.buildEnv.run_command(command, self.build_path, context)
class CMakeBuilder(MakeBuilder): class CMakeBuilder(MakeBuilder):
def _configure(self, context): def _configure(self, context):
@ -357,6 +379,10 @@ class MesonBuilder(Builder):
command = "{} -v install".format(self.buildEnv.ninja_command) command = "{} -v install".format(self.buildEnv.ninja_command)
self.buildEnv.run_command(command, self.build_path, context) self.buildEnv.run_command(command, self.build_path, context)
def _make_dist(self, context):
command = "{} -v dist".format(self.buildEnv.ninja_command)
self.buildEnv.run_command(command, self.build_path, context)
class GradleBuilder(Builder): class GradleBuilder(Builder):
gradle_target = "build" gradle_target = "build"

View File

@ -942,9 +942,17 @@ class Builder:
builders = (dep.builder for dep in self.targets.values() if (dep.builder and not dep.skip)) builders = (dep.builder for dep in self.targets.values() if (dep.builder and not dep.skip))
for builder in builders: for builder in builders:
if self.options.make_dist and builder.name == self.options.targets:
continue
print("build {} :".format(builder.name)) print("build {} :".format(builder.name))
builder.build() builder.build()
if self.options.make_dist:
dep = self.targets[self.options.targets]
builder = dep.builder
print("make dist {}:".format(builder.name))
builder.make_dist()
def run(self): def run(self):
try: try:
print("[INSTALL PACKAGES]") print("[INSTALL PACKAGES]")
@ -979,7 +987,11 @@ def parse_args():
parser.add_argument('--skip-source-prepare', action='store_true', parser.add_argument('--skip-source-prepare', action='store_true',
help="Skip the source download part") help="Skip the source download part")
parser.add_argument('--build-deps-only', action='store_true', parser.add_argument('--build-deps-only', action='store_true',
help=("Build only the dependencies of the specified targets.")) help="Build only the dependencies of the specified targets.")
parser.add_argument('--make-dist', action='store_true',
help="Build distrubution (dist) source archive")
parser.add_argument('--make-release', action='store_true',
help="Build a release version")
subgroup = parser.add_argument_group('advanced') subgroup = parser.add_argument_group('advanced')
subgroup.add_argument('--no-cert-check', action='store_true', subgroup.add_argument('--no-cert-check', action='store_true',
help="Skip SSL certificate verification during download") help="Skip SSL certificate verification during download")

View File

@ -4,21 +4,35 @@ set -e
BASE_DIR="BUILD_${PLATFORM}" BASE_DIR="BUILD_${PLATFORM}"
NIGHTLY_ARCHIVES_DIR=${HOME}/NIGHTLY_ARCHIVES NIGHTLY_ARCHIVES_DIR=${HOME}/NIGHTLY_ARCHIVES
RELEASE_ARCHIVES_DIR=${HOME}/RELEASE_ARCHIVES
SSH_KEY=${TRAVIS_BUILD_DIR}/travis/travisci_builder_id_key SSH_KEY=${TRAVIS_BUILD_DIR}/travis/travisci_builder_id_key
mkdir -p ${NIGHTLY_ARCHIVES_DIR} mkdir -p ${NIGHTLY_ARCHIVES_DIR}
mkdir -p ${RELEASE_ARCHIVES_DIR}
function make_nightly_archive { function make_archive {
ARCHIVE_NAME="${1}_$(date +%Y-%m-%d).tar.gz" if [[ "$MAKE_RELEASE" == "0" ]]
then
ARCHIVE_PATH="${NIGHTLY_ARCHIVES_DIR}/${1}_$(date +%Y-%m-%d).tar.gz"
else
ARCHIVE_PATH="${RELEASE_ARCHIVES_DIR}/${1}-${TRAVIS_TAG}.tar.gz"
fi
( (
cd ${BASE_DIR}/INSTALL/bin cd ${BASE_DIR}/INSTALL/bin
tar -czf "${NIGHTLY_ARCHIVES_DIR}/$ARCHIVE_NAME" $2 tar -czf "${ARCHIVE_PATH}" $2
) )
} }
cd ${HOME} cd ${HOME}
if [[ "$TRAVIS_EVENT_TYPE" = "cron" ]] if [[ $TRAVIS_TAG =~ ^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+ ]]
then
MAKE_RELEASE=1
else
MAKE_RELEASE=0
fi
if [[ "$TRAVIS_EVENT_TYPE" == "cron" || "$MAKE_RELEASE" == "1" ]]
then then
if [[ ${PLATFORM} = android* ]] if [[ ${PLATFORM} = android* ]]
then then
@ -33,6 +47,8 @@ then
for TARGET in ${TARGETS} for TARGET in ${TARGETS}
do do
echo $TARGET echo $TARGET
if [[ "$TRAVIS_EVENT_TYPE" == "cron" ]]
then
${TRAVIS_BUILD_DIR}/kiwix-build.py \ ${TRAVIS_BUILD_DIR}/kiwix-build.py \
--target-platform $PLATFORM \ --target-platform $PLATFORM \
--build-deps-only \ --build-deps-only \
@ -60,23 +76,46 @@ EOF
tar -czf ${ARCHIVE_NAME} INSTALL manifest.txt ${MESON_FILE} ${ANDROID_NDK_DIR} tar -czf ${ARCHIVE_NAME} INSTALL manifest.txt ${MESON_FILE} ${ANDROID_NDK_DIR}
scp -i ${SSH_KEY} ${ARCHIVE_NAME} nightlybot@download.kiwix.org:/var/www/tmp.kiwix.org/ci/ scp -i ${SSH_KEY} ${ARCHIVE_NAME} nightlybot@download.kiwix.org:/var/www/tmp.kiwix.org/ci/
) )
fi
${TRAVIS_BUILD_DIR}/kiwix-build.py --hide-progress --target-platform $PLATFORM ${TARGET} if [[ "$MAKE_RELEASE" == "1" ]]
then
${TRAVIS_BUILD_DIR}/kiwix-build.py \
--hide-progress \
--make-release \
--target-platform $PLATFORM ${TARGET}
if [[ "$PLATFORM" == "native_dyn" ]]
then
${TRAVIS_BUILD_DIR}/kiwix-build.py \
--hide-progress \
--make-release \
--make-dist \
--target-platform $PLATFORM ${TARGET}
fi
else
${TRAVIS_BUILD_DIR}/kiwix-build.py \
--hide-progress \
--target-platform $PLATFORM ${TARGET}
fi
rm ${BASE_DIR}/.install_packages_ok rm ${BASE_DIR}/.install_packages_ok
done done
# We have build every thing. Now create archives for public deployement. # We have build every thing. Now create archives for public deployement.
case ${PLATFORM} in case ${PLATFORM} in
native_dyn)
#[TODO] Copy archive somewhere
#scp ${BASE_DIR}/${TARGET}/${TARGET}-${TARGET-version}.tar.gz ${SOMEWHERE}
;;
native_static) native_static)
make_nightly_archive kiwix_tools_linux64 "kiwix-install kiwix-manage kiwix-read kiwix-search kiwix-serve" make_archive kiwix_tools_linux64 "kiwix-install kiwix-manage kiwix-read kiwix-search kiwix-serve"
make_nightly_archive zim-tools_linux64 "zimbench zimdump zimsearch zimdiff zimpatch zimsplit" make_archive zim-tools_linux64 "zimbench zimdump zimsearch zimdiff zimpatch zimsplit"
make_nightly_archive zimwriterfs_linux64 "zimwriterfs" make_archive zimwriterfs_linux64 "zimwriterfs"
;; ;;
win32_static) win32_static)
make_nightly_archive kiwix-tools_win32 "kiwix-install.exe kiwix-manage.exe kiwix-read.exe kiwix-search.exe kiwix-serve.exe" make_archive kiwix-tools_win32 "kiwix-install.exe kiwix-manage.exe kiwix-read.exe kiwix-search.exe kiwix-serve.exe"
;; ;;
armhf_static) armhf_static)
make_nightly_archive kiwix-tools_armhf "kiwix-install kiwix-manage kiwix-read kiwix-search kiwix-serve" make_archive kiwix-tools_armhf "kiwix-install kiwix-manage kiwix-read kiwix-search kiwix-serve"
;; ;;
android_*) android_*)
APK_NAME="kiwix-${PLATFORM}" APK_NAME="kiwix-${PLATFORM}"

View File

@ -3,6 +3,7 @@
set -e set -e
NIGHTLY_ARCHIVES_DIR=${HOME}/NIGHTLY_ARCHIVES NIGHTLY_ARCHIVES_DIR=${HOME}/NIGHTLY_ARCHIVES
RELEASE_ARCHIVES_DIR=${HOME}/RELEASE_ARCHIVES
SSH_KEY=travis/travisci_builder_id_key SSH_KEY=travis/travisci_builder_id_key
NIGHTLY_ARCHIVES=$(find $NIGHTLY_ARCHIVES_DIR -type f) NIGHTLY_ARCHIVES=$(find $NIGHTLY_ARCHIVES_DIR -type f)
@ -12,3 +13,11 @@ then
${NIGHTLY_ARCHIVES} \ ${NIGHTLY_ARCHIVES} \
nightlybot@download.kiwix.org:/var/www/download.kiwix.org/nightly/$(date +%Y-%m-%d) nightlybot@download.kiwix.org:/var/www/download.kiwix.org/nightly/$(date +%Y-%m-%d)
fi fi
RELEASE_ARCHIVES=$(find $RELEASE_ARCHIVES_DIR -type f)
if [[ "x$RELEASE_ARCHIVES" != "x" ]]
then
scp -vrp -i ${SSH_KEY} \
${RELEASE_ARCHIVES} \
nightlybot@downoald.kiwix.org:/var/www/download.kiwix.org/releases
fi