forked from evansde77/cirrus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request evansde77#175 from evansde77/feature/nightly-release
Feature/nightly release
- Loading branch information
Showing
7 changed files
with
187 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#!/usr/bin/env python | ||
|
||
import re | ||
import datetime | ||
|
||
from cirrus.configuration import load_configuration | ||
|
||
DEFAULT_FORMAT = "%Y%m%d" | ||
|
||
|
||
def nightly_config(conf=None): | ||
""" | ||
get the nightly config settings from | ||
the release section | ||
""" | ||
result = { | ||
"nightly_format": DEFAULT_FORMAT, | ||
"nightly_separator": "-nightly-" | ||
} | ||
if not conf: | ||
conf = load_configuration() | ||
if not conf.has_section('release'): | ||
return result | ||
result['nightly_format'] = conf.get_param("release", "nightly_format", result['nightly_format']) | ||
result['nightly_separator'] = conf.get_param("release", "nightly_separator", result['nightly_separator']) | ||
return result | ||
|
||
|
||
def is_nightly(version): | ||
""" | ||
return True/False if the version string | ||
provided matches a nightly format. | ||
""" | ||
conf = nightly_config() | ||
reg = "^[0-9]+\.[0-9]+\.[0-9]+{}".format(conf['nightly_separator']) | ||
matcher = re.compile(reg) | ||
elems = matcher.split(version, 1) | ||
if len(elems) == 2: | ||
return True | ||
return False | ||
|
||
|
||
def new_nightly(): | ||
""" | ||
generate a new nightly version | ||
""" | ||
cirrus_conf = load_configuration() | ||
nightly_conf = nightly_config(cirrus_conf) | ||
now = datetime.datetime.now() | ||
ts = now.strftime(nightly_conf['nightly_format']) | ||
current = cirrus_conf.package_version() | ||
|
||
nightly = "{version}{sep}{ts}".format( | ||
version=current, | ||
sep=nightly_conf['nightly_separator'], | ||
ts=ts | ||
) | ||
return nightly | ||
|
||
|
||
def remove_nightly(ghc): | ||
""" | ||
remove the nightly part from the cirrus.conf version | ||
""" | ||
cirrus_conf = load_configuration() | ||
nightly_conf = nightly_config(cirrus_conf) | ||
current = cirrus_conf.package_version() | ||
if is_nightly(current): | ||
new_version = current.split(nightly_conf['nightly_separator'], 1)[0] | ||
cirrus_conf.update_package_version(new_version) | ||
ghc.commit_files_optional_push( | ||
"remove nightly tag from cirrus.conf", | ||
False, | ||
"cirrus.conf" | ||
) | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters