Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pjarosik committed Sep 7, 2021
2 parents e55de9b + 2fbf369 commit 861af18
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
9 changes: 7 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pipeline {

options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(daysToKeepStr: '14'))
buildDiscarder(logRotator(daysToKeepStr: '365'))
}

stages {
Expand All @@ -38,7 +38,7 @@ pipeline {
stage('Configure') {
steps {
echo 'Configuring build ...'
sh "python '${env.WORKSPACE}/scripts/cfg_build.py' --source_dir '${env.WORKSPACE}' --us4r_dir '${env.US4R_INSTALL_DIR}/$US4R_REQUIRED_TAG' --src_branch_name ${env.BRANCH_NAME} --targets py matlab docs --run_targets tests --options ARRUS_EMBED_DEPS=ON"
sh "python '${env.WORKSPACE}/scripts/cfg_build.py' --source_dir '${env.WORKSPACE}' --us4r_dir '${env.US4R_INSTALL_DIR}/$US4R_REQUIRED_TAG' --src_branch_name ${env.BRANCH_NAME} --targets py matlab docs --run_targets tests --options ARRUS_EMBED_DEPS=ON ARRUS_APPEND_VERSION_SUFFIX_DATE=${isDevelopOnOff()}"
}
}
stage('Build') {
Expand Down Expand Up @@ -134,6 +134,11 @@ def getBranchName() {
return env.BRANCH_NAME == "master" ? "master" : "develop";
}

def isDevelopOnOff() {
return "ON";
// return env.BRANCH_NAME == "develop" ? "ON" : "OFF";
}

def getBuildName(build) {
wrap([$class: 'BuildUser']) {
return "#${build.id} (${env.BUILD_USER_ID})";
Expand Down
2 changes: 1 addition & 1 deletion scripts/create_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _search_for_single_pattern(pattern, content):


def get_required_firmware_version(install_dir):
with open(os.path.join(install_dir, "Version.rst")) as f:
with open(os.path.join(install_dir, "VERSION.rst")) as f:
content = f.readlines()
arrus_version = content[0].strip()
# Search for firmware version.
Expand Down
32 changes: 15 additions & 17 deletions scripts/publish_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import requests
import errno
import logging
from datetime import date

COLOR_ERROR = '\033[91m'
COLOR_END = '\033[0m'
Expand Down Expand Up @@ -58,29 +59,29 @@ def main():

if install_dir is None:
raise ValueError("%s environment variable should be declared "
"or provided as input parameter."
%(INSTALL_ENVIRON))
"or provided as input parameter." %(INSTALL_ENVIRON))

publish(install_dir, token, src_branch_name, repository_name, build_id)


def publish(install_dir, token, src_branch_name, repository_name, build_id):
timestamp = date.today().strftime("%Y%m%d")
version = get_version(install_dir)
if src_branch_name == "master" \
or VERSION_TAG_PATTERN.match(src_branch_name):
release_tag = version
package_name = "arrus-" + release_tag
elif src_branch_name == "develop":
release_tag = version + "-dev"
# Note: the same pattern is used in the root CMakeLists.txt
package_name = "arrus-" + version + "-dev-" + timestamp
else:
raise ValueError(
"Releases from branch %s are not allowed to be published!")

package_name = "arrus-" + release_tag
archive_path = os.path.join(install_dir, f"arrus-{version}.zip")
raise ValueError("Releases from branch %s are not allowed to be published!")

package_name += ".zip"
archive_path = os.path.join(install_dir, f"arrus-{version}.zip")

release_description = "build: %s, host: %s" % (build_id, platform.node())
release_description = f"date: {timestamp}, tag: {release_tag}, build: {build_id}, host: {platform.node()}"
response = create_release(repository_name, release_tag, token, release_description)

if not response.ok:
Expand All @@ -93,8 +94,9 @@ def publish(install_dir, token, src_branch_name, repository_name, build_id):
r = get_release_by_tag(repository_name, release_tag, token)
r.raise_for_status()
release_id = r.json()["id"]
r = edit_release(repository_name, release_id, release_tag,
token, release_description)
description_body = r.json()["body"]
release_description = description_body + "\n" + release_description
r = edit_release(repository_name, release_id, release_tag, token, release_description)
r.raise_for_status()
else:
print(resp)
Expand All @@ -107,13 +109,9 @@ def publish(install_dir, token, src_branch_name, repository_name, build_id):
r.raise_for_status()
current_assets = r.json()

if len(current_assets) > 1:
raise RuntimeError("Release %d contains more than one asset!" % release_id)

if len(current_assets) == 1:
asset_id = current_assets[0]["id"]
r = delete_asset(repository_name, asset_id, token)

existing_assets = [asset for asset in current_assets if asset["name"] == package_name]
if len(existing_assets) > 0:
raise RuntimeError(f"Release {release_id} contains more than one asset with name: {package_name}")
with open(archive_path, "rb") as f:
data = f.read()
r = upload_asset(repository_name, release_id, package_name, token, data)
Expand Down

0 comments on commit 861af18

Please sign in to comment.