mirror of https://github.com/CGAL/cgal
New script to publish internal releases
This commit is contained in:
parent
3c2ce13dd9
commit
ed777cafc8
|
|
@ -0,0 +1,51 @@
|
||||||
|
'''Python module to create and publish CGAL releases from a branch'''
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
class Release:
|
||||||
|
'''class to create a CGAL release from a branch
|
||||||
|
optionally, the release can be internal
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, branch, internal=False) :
|
||||||
|
self.branch = branch
|
||||||
|
self.internal = internal
|
||||||
|
self.cwd = f'$HOME/CGAL/create_internal_release-{self.branch}-branch'
|
||||||
|
self.repo = f'$HOME/CGAL/branches/CGAL-{self.branch}-branch.git'
|
||||||
|
self.extra_options = ' --public'
|
||||||
|
|
||||||
|
def command(self):
|
||||||
|
'''return the command to create and publish the release'''
|
||||||
|
return f"PATH=/home/lrineau/bin-cmake3:/bin:/usr/bin:/home/lrineau/bin; cd {self.cwd} && /usr/bin/time scl enable rh-git29 -- $HOME/bin/create_release {self.repo}{self.extra_options} --do-it"
|
||||||
|
|
||||||
|
def __str__(self) :
|
||||||
|
msg = f"{'internal ' if self.internal else ''}release from {self.branch}\n" \
|
||||||
|
f"cwd: {self.cwd}\nrepo: {self.repo}\n" \
|
||||||
|
f"command:\n{self.command()}"
|
||||||
|
return msg
|
||||||
|
|
||||||
|
def __call__(self) :
|
||||||
|
if os.system(self.command()) != 0 :
|
||||||
|
raise RuntimeError(f"Error while creating {'internal ' if self.internal else ''}release from {self.branch}")
|
||||||
|
|
||||||
|
INTERNAL = True
|
||||||
|
|
||||||
|
class InternalRelease(Release) :
|
||||||
|
'''class to create an internal CGAL release from a branch'''
|
||||||
|
def __init__(self, branch) :
|
||||||
|
super().__init__(branch, Release.INTERNAL)
|
||||||
|
self.extra_options = ' --integration'
|
||||||
|
|
||||||
|
integration = InternalRelease("integration")
|
||||||
|
integration.repo = '$HOME/CGAL/branches/integration.git'
|
||||||
|
integration.cwd = '$HOME/CGAL/create_internal_release'
|
||||||
|
master = Release("master")
|
||||||
|
master.repo = '$HOME/CGAL/branches/master.git'
|
||||||
|
master.cwd = '$HOME/CGAL/create_internal_release'
|
||||||
|
|
||||||
|
def release(branch) :
|
||||||
|
'''Convenience function to create a release from a branch'''
|
||||||
|
return Release(branch)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print("This file is a Python module. Use create_internal_release_of_the_day.py instead.")
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
#! /bin/python3
|
||||||
|
|
||||||
|
'''This script is called by a cron job every day.
|
||||||
|
It creates and publish a release tarball.
|
||||||
|
'''
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import datetime
|
||||||
|
import locale
|
||||||
|
from pathlib import Path
|
||||||
|
sys.path.append(Path(__file__))
|
||||||
|
from cgal_release import release, integration, master
|
||||||
|
|
||||||
|
# Define a dictionary that maps day of the week to an action
|
||||||
|
actions = {
|
||||||
|
"Monday": integration,
|
||||||
|
"Tuesday": integration,
|
||||||
|
"Wednesday": integration,
|
||||||
|
"Thursday": integration,
|
||||||
|
"Friday": release("5.5"),
|
||||||
|
"Saturday": release("5.4"),
|
||||||
|
"Sunday": master
|
||||||
|
}
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Get the current day of the week, or get it from the command line
|
||||||
|
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
|
||||||
|
try:
|
||||||
|
DAY_OF_THE_WEEK = sys.argv[1]
|
||||||
|
except IndexError:
|
||||||
|
DAY_OF_THE_WEEK = datetime.datetime.now().strftime("%A")
|
||||||
|
|
||||||
|
# Look up the action for the current day of the week in the dictionary
|
||||||
|
create_release = actions[DAY_OF_THE_WEEK]
|
||||||
|
|
||||||
|
# Then create the release tarball
|
||||||
|
if os.system(create_release.command() + " --dont-do-it") != 0 :
|
||||||
|
raise RuntimeError(f"ERROR while creating release tarball")
|
||||||
Loading…
Reference in New Issue