From 5e1398a7e5b82dadef5e83643e577f077ad08077 Mon Sep 17 00:00:00 2001 From: Paulchen-Panther Date: Sat, 15 Jun 2019 15:46:56 +0200 Subject: [PATCH 1/4] Release preparation OSX packaging is currently broken. CPack is now called individually so that the make process is no longer displayed incorrectly in Travis / Azure. The variable PACKAGES in the build script is no longer overwritten, so in travis / Azure you can globally assign the variable and start a package build process manually. Signed-off-by: Paulchen-Panther --- .azure.yml | 24 ++++++++++++++++++++---- .ci/ci_build.sh | 7 +++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.azure.yml b/.azure.yml index 74604fea..a7a19c96 100644 --- a/.azure.yml +++ b/.azure.yml @@ -31,8 +31,16 @@ jobs: DOCKER_TAG: $(dockerTag) DOCKER_NAME: $(dockerName) PLATFORM: $(platform) - - bash: ./.ci/ci_deploy.sh - displayName: 'Upload $(dockerName)' + - task: CopyFiles@2 + displayName: 'Copy Files' + inputs: + contents: '**/deploy/**' + TargetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: $(dockerName)' + inputs: + pathtoPublish: '$(Build.ArtifactStagingDirectory)' + artifactName: $(dockerTag) - job: macOS pool: @@ -44,5 +52,13 @@ jobs: displayName: 'Install dependencies' - bash: ./.ci/ci_build.sh displayName: 'Build macOS 10.13' - - bash: ./.ci/ci_deploy.sh - displayName: 'Upload macOS 10.13' + - task: CopyFiles@2 + displayName: 'Copy Files' + inputs: + contents: '**/deploy/**' + TargetFolder: '$(Build.ArtifactStagingDirectory)' + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: macOS 10.13' + inputs: + pathtoPublish: '$(Build.ArtifactStagingDirectory)' + artifactName: 'macOS' diff --git a/.ci/ci_build.sh b/.ci/ci_build.sh index 016dae6e..5e53f1e5 100755 --- a/.ci/ci_build.sh +++ b/.ci/ci_build.sh @@ -16,7 +16,7 @@ fi # set environment variables BUILD_TYPE="Debug" -PACKAGES="" +[ -z "${PACKAGES}" ] && PACKAGES="" [ -z "${PLATFORM}" ] && PLATFORM="x11" # Detect number of processor cores @@ -50,7 +50,10 @@ if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then mkdir ${CI_BUILD_DIR}/deploy || exit 1 cd build cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr .. || exit 2 - make -j ${JOBS} ${PACKAGES} || exit 3 + make -j ${JOBS} || exit 3 + if [[ "$PACKAGES" == 'package' ]]; then + sudo cpack + fi echo "---> Copy binaries and packages to folder: ${CI_BUILD_DIR}/deploy" cp -v ${CI_BUILD_DIR}/build/bin/h* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && cp -v ${CI_BUILD_DIR}/build/Hyperion-* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && From c7922b2fd4a077de2b0df60760c109134fd9afd9 Mon Sep 17 00:00:00 2001 From: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Sun, 16 Jun 2019 09:24:01 +0200 Subject: [PATCH 2/4] macOS package creation fixed https://en.wikipedia.org/wiki/System_Integrity_Protection --- .ci/ci_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/ci_build.sh b/.ci/ci_build.sh index 5e53f1e5..6fb10e44 100755 --- a/.ci/ci_build.sh +++ b/.ci/ci_build.sh @@ -49,7 +49,7 @@ if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then mkdir build || exit 1 mkdir ${CI_BUILD_DIR}/deploy || exit 1 cd build - cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr .. || exit 2 + cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ../ || exit 2 make -j ${JOBS} || exit 3 if [[ "$PACKAGES" == 'package' ]]; then sudo cpack From 93b9028b7d39699331a70b5d52fb28891492fc18 Mon Sep 17 00:00:00 2001 From: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Wed, 19 Jun 2019 19:04:54 +0200 Subject: [PATCH 3/4] GitHub package creation/upload --- .azure.yml | 127 ++++++++++++++++++++++++++++++++----- .ci/ci_build.sh | 49 ++++---------- .ci/ci_deploy.sh | 67 ------------------- .travis.yml | 2 - CMakeLists.txt | 33 ++++++++-- cmake/packages.cmake | 10 ++- test/jsonchecks/version.py | 9 +++ version.json | 27 ++------ 8 files changed, 173 insertions(+), 151 deletions(-) delete mode 100755 .ci/ci_deploy.sh create mode 100644 test/jsonchecks/version.py diff --git a/.azure.yml b/.azure.yml index a7a19c96..f0f0e928 100644 --- a/.azure.yml +++ b/.azure.yml @@ -1,5 +1,11 @@ jobs: + +###################### +###### Linux ######### +###################### + - job: Linux + timeoutInMinutes: 120 pool: vmImage: 'ubuntu-16.04' strategy: @@ -7,9 +13,11 @@ jobs: AMD64 (x64): dockerTag: 'amd64' dockerName: 'Debian Stretch (AMD64)' + platform: 'x11' i386 (x86): dockerTag: 'i386' dockerName: 'Debian Stretch (i386)' + platform: 'x11' ARMv6hf (Raspberry Pi v1 & ZERO): dockerTag: 'armv6hf' dockerName: 'Debian Stretch (Raspberry Pi v1 & ZERO)' @@ -22,43 +30,130 @@ jobs: dockerTag: 'aarch64' dockerName: 'ARMv8 (Generic AARCH64)' platform: 'amlogic' + steps: - - checkout: self - submodules: recursive + - checkout: self # represents the repo where the initial Pipelines YAML file was found + submodules: recursive # set to 'recursive' to get submodules of submodules + + # build process - bash: ./.ci/ci_build.sh displayName: 'Build $(dockerName)' env: DOCKER_TAG: $(dockerTag) DOCKER_NAME: $(dockerName) PLATFORM: $(platform) - - task: CopyFiles@2 - displayName: 'Copy Files' + + # read version.json and generate pipeline variables + - task: oneLuckiDevJson2Variable@1 inputs: - contents: '**/deploy/**' - TargetFolder: '$(Build.ArtifactStagingDirectory)' + jsonFile: 'version.json' + shouldPrefixVariables: true + variablePrefix: 'json' + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Read and generate pipeline variables' + + # copy files + - bash: 'cp -v deploy/Hyperion.NG-* $(Build.ArtifactStagingDirectory)' + workingDirectory: '$(Build.SourcesDirectory)' + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Collecting deployable artifacts' + + # publish artifacts - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: $(dockerName)' inputs: pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: $(dockerTag) + ArtifactName: $(dockerTag) + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Publish deployables artifacts' + + # assign latest tag variable + - bash: echo "##vso[task.setvariable variable=latestTag]$(git tag | tail -1)" + displayName: "Read latest tag" + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + + # create or update github release + - task: GithubRelease@0 + inputs: + gitHubConnection: Hyperion.NG + repositoryName: $(Build.Repository.Name) + action: edit + target: $(Build.SourceVersion) + tagSource: manual + tag: '$(latestTag)' + title: '# $(latestTag) v$(json.versionnr)' + releaseNotesSource: input + releaseNotes: $(Build.SourceVersionMessage) + assets: '$(Build.ArtifactStagingDirectory)/*' + assetUploadMode: 'replace' + isPreRelease: true + addChangeLog: false + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: Create/Update GitHub release + +###################### +###### macOS ######### +###################### - job: macOS + timeoutInMinutes: 120 pool: vmImage: 'macOS-10.13' + steps: - - checkout: self - submodules: recursive + - checkout: self # represents the repo where the initial Pipelines YAML file was found + submodules: recursive # set to 'recursive' to get submodules of submodules + + # install dependencies - bash: ./.ci/ci_install.sh displayName: 'Install dependencies' + + # build process - bash: ./.ci/ci_build.sh displayName: 'Build macOS 10.13' - - task: CopyFiles@2 - displayName: 'Copy Files' + + # read version.json and generate pipeline variables + - task: oneLuckiDevJson2Variable@1 inputs: - contents: '**/deploy/**' - TargetFolder: '$(Build.ArtifactStagingDirectory)' + jsonFile: 'version.json' + shouldPrefixVariables: true + variablePrefix: 'json' + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Read and generate pipeline variables' + + # copy files + - bash: 'cp -v build/Hyperion.NG-* $(Build.ArtifactStagingDirectory)' + workingDirectory: '$(Build.SourcesDirectory)' + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Collecting deployable artifacts' + + # publish artifacts - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: macOS 10.13' inputs: pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: 'macOS' + ArtifactName: 'macos' + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Publish deployables artifacts' + + # generate latest tag variable + - bash: echo "##vso[task.setvariable variable=latestTag]$(git tag | tail -1)" + displayName: "Read latest tag" + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + + # create or update github release + - task: GithubRelease@0 + inputs: + gitHubConnection: Hyperion.NG + repositoryName: $(Build.Repository.Name) + action: edit + target: $(Build.SourceVersion) + tagSource: manual + tag: '$(latestTag)' + title: '# $(latestTag) v$(json.versionnr)' + releaseNotesSource: input + releaseNotes: $(Build.SourceVersionMessage) + assets: '$(Build.ArtifactStagingDirectory)/*' + assetUploadMode: 'replace' + isPreRelease: true + addChangeLog: false + condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: Create/Update GitHub release diff --git a/.ci/ci_build.sh b/.ci/ci_build.sh index 6fb10e44..29a8638d 100755 --- a/.ci/ci_build.sh +++ b/.ci/ci_build.sh @@ -14,50 +14,28 @@ else CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" fi -# set environment variables -BUILD_TYPE="Debug" -[ -z "${PACKAGES}" ] && PACKAGES="" -[ -z "${PLATFORM}" ] && PLATFORM="x11" - -# Detect number of processor cores -# default is 4 jobs -if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then - JOBS=$(sysctl -n hw.ncpu) - PLATFORM=osx -elif [[ "$CI_NAME" == 'linux' ]]; then - JOBS=$(nproc) -fi -echo "compile jobs: ${JOBS:=4}" +# set environment variables if not exists +[ -z "${BUILD_TYPE}" ] && BUILD_TYPE="Debug" # Determine cmake build type; tag builds are Release, else Debug -if [ -n "${TRAVIS_TAG:-}" ] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then +if [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then BUILD_TYPE=Release fi -# Determine package creation; True for cron/schedule and tag builds -if [ "${TRAVIS_EVENT_TYPE:-}" == 'cron' ] || [ -n "${TRAVIS_TAG:-}" ] || [[ $BUILD_REASON == "Schedule" ]] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then - PACKAGES="package" -fi - # Determie -dev appends to platform; # Commented because tests are currently broken # [ "${TRAVIS_EVENT_TYPE:-}" != 'cron' -a -z "${TRAVIS_TAG:-}" ] && PLATFORM=${PLATFORM}-dev -# Build the package on osx or docker for linux +# Build the package on osx or linux if [[ "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then # compile prepare mkdir build || exit 1 mkdir ${CI_BUILD_DIR}/deploy || exit 1 cd build - cmake -DPLATFORM=$PLATFORM -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ../ || exit 2 - make -j ${JOBS} || exit 3 - if [[ "$PACKAGES" == 'package' ]]; then - sudo cpack - fi - echo "---> Copy binaries and packages to folder: ${CI_BUILD_DIR}/deploy" - cp -v ${CI_BUILD_DIR}/build/bin/h* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && - cp -v ${CI_BUILD_DIR}/build/Hyperion-* ${CI_BUILD_DIR}/deploy/ 2>/dev/null || : && + cmake -DPLATFORM="osx" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_INSTALL_PREFIX:PATH=/usr/local ../ || exit 2 + make -j $(sysctl -n hw.ncpu) package || exit 3 exit 0; + exit 1 || { echo "---> Hyperion compilation failed! Abort"; exit 4; } elif [[ "$CI_NAME" == 'linux' ]]; then echo "Compile Hyperion with DOCKER_TAG = ${DOCKER_TAG} and friendly name DOCKER_NAME = ${DOCKER_NAME}" # take ownership of deploy dir @@ -68,13 +46,12 @@ elif [[ "$CI_NAME" == 'linux' ]]; then -v "${CI_BUILD_DIR}/deploy:/deploy" \ -v "${CI_BUILD_DIR}:/source:ro" \ hyperionproject/hyperion-ci:$DOCKER_TAG \ - /bin/bash -c "mkdir build && cp -r source/. /build && - cd /build && mkdir build && cd build && - cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} .. || exit 2 && - make -j ${JOBS} ${PACKAGES} || exit 3 && - echo '---> Copy binaries and packages to host folder: ${CI_BUILD_DIR}/deploy' && - cp -v /build/build/bin/h* /deploy/ 2>/dev/null || : && - cp -v /build/build/Hyperion-* /deploy/ 2>/dev/null || : && + /bin/bash -c "mkdir hyperion.ng && cp -r source/. /hyperion.ng && + cd /hyperion.ng && mkdir build && cd build && + cmake -DPLATFORM=${PLATFORM} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DDOCKER_PLATFORM=${DOCKER_TAG} ../ || exit 2 && + make -j $(nproc) package || exit 3 && + cp /hyperion.ng/build/bin/h* /deploy/ 2>/dev/null || : && + cp /hyperion.ng/build/Hyperion.NG-* /deploy/ 2>/dev/null || : && exit 0; exit 1 " || { echo "---> Hyperion compilation failed! Abort"; exit 4; } diff --git a/.ci/ci_deploy.sh b/.ci/ci_deploy.sh deleted file mode 100755 index df3ef780..00000000 --- a/.ci/ci_deploy.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -# detect CI -if [ -n "${TRAVIS-}" ]; then - # Travis-CI - CI_NAME="$(echo "$TRAVIS_OS_NAME" | tr '[:upper:]' '[:lower:]')" - CI_BUILD_DIR="$TRAVIS_BUILD_DIR" -elif [ "$SYSTEM_COLLECTIONID" != "" ]; then - # Azure Pipelines - CI_NAME="$(echo "$AGENT_OS" | tr '[:upper:]' '[:lower:]')" - CI_BUILD_DIR="$BUILD_SOURCESDIRECTORY" -else - # for executing in non ci environment - CI_NAME="$(uname -s | tr '[:upper:]' '[:lower:]')" -fi - -# sf_upload -# { -# echo "Uploading following files: ${1} to dir /hyperion-project/${2}" -# -# } - -# append current Date to filename (just packages no binaries) -appendDate() -{ - D=$(date +%Y-%m-%d) - for F in $CI_BUILD_DIR/deploy/Hy* - do - mv "$F" "${F%.*}-$D.${F##*.}" - done -} - -# append friendly name (just packages no binaries) -appendName() -{ - for F in $CI_BUILD_DIR/deploy/Hy* - do - mv "$F" "${F%.*}-($DOCKER_NAME).${F##*.}" - done -} - -# get all files to deploy (just packages no binaries) -getFiles() -{ - FILES="" - for f in $CI_BUILD_DIR/deploy/Hy*; - do FILES+="${f} "; - done; -} - -if [[ $CI_NAME == 'linux' || "$CI_NAME" == 'osx' || "$CI_NAME" == 'darwin' ]]; then - if [[ -n $TRAVIS_TAG ]] || [[ $BUILD_SOURCEBRANCH == *"refs/tags"* ]]; then - echo "tag upload" - appendName - appendDate - getFiles - # sf_upload $FILES release - elif [[ $TRAVIS_EVENT_TYPE == 'cron' ]] || [[ $BUILD_REASON == "Schedule" ]]; then - echo "cron/schedule upload" - appendName - appendDate - getFiles - # sf_upload $FILES dev/alpha - else - echo "Direct pushed no upload, PRs not possible" - fi -fi diff --git a/.travis.yml b/.travis.yml index 38bd18bb..44ad22bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,4 @@ jobs: script: - ./.ci/ci_build.sh -after_success: - - ./.ci/ci_deploy.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d030199..3491ce62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,11 +18,29 @@ if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) endif(CCACHE_FOUND) -SET ( HYPERION_VERSION_STABLE OFF ) -SET ( HYPERION_VERSION_MAJOR 2 ) -SET ( HYPERION_VERSION_MINOR 0 ) -SET ( HYPERION_VERSION_PATCH 0 ) +# Read version from version.json +EXECUTE_PROCESS ( + COMMAND python test/jsonchecks/version.py ${PROJECT_SOURCE_DIR}/version.json + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE RETURN_VERSION +) +SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9_]+)?") +IF( ${RETURN_VERSION} MATCHES ${VERSION_REGEX} ) + STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_]+)" VERSION_PARTS ${RETURN_VERSION}) + LIST(GET VERSION_PARTS 0 VERSION_MAJOR) + LIST(GET VERSION_PARTS 1 VERSION_MINOR) + LIST(GET VERSION_PARTS 2 VERSION_PATCH) +ELSE( ${RETURN_VERSION} MATCHES ${VERSION_REGEX} ) + message( FATAL_ERROR "Failed to parse version.json string properly. Expect X.Y.Z.") +ENDIF() + +SET ( HYPERION_VERSION_STABLE OFF ) +SET ( HYPERION_VERSION_MAJOR ${VERSION_MAJOR} ) +SET ( HYPERION_VERSION_MINOR ${VERSION_MINOR} ) +SET ( HYPERION_VERSION_PATCH ${VERSION_PATCH} ) + +# Set build variables SET ( DEFAULT_AMLOGIC OFF ) SET ( DEFAULT_DISPMANX OFF ) SET ( DEFAULT_OSX OFF ) @@ -121,9 +139,10 @@ if ( "${PLATFORM}" MATCHES "-dev" ) SET ( DEFAULT_TESTS ON ) endif() -STRING( TOUPPER "-DPLATFORM_${PLATFORM}" PLATFORM_DEFINE) -STRING( REPLACE "-DEV" "" PLATFORM_DEFINE "${PLATFORM_DEFINE}" ) -ADD_DEFINITIONS( ${PLATFORM_DEFINE} ) +# is this necessary? +# STRING( TOUPPER "-DPLATFORM_${PLATFORM}" PLATFORM_DEFINE) +# STRING( REPLACE "-DEV" "" PLATFORM_DEFINE "${PLATFORM_DEFINE}" ) +# ADD_DEFINITIONS( ${PLATFORM_DEFINE} ) # set the build options option(ENABLE_AMLOGIC "Enable the AMLOGIC video grabber" ${DEFAULT_AMLOGIC} ) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index 5e9765b3..ffc0ac72 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -24,10 +24,16 @@ ENDIF() # Apply to all packages, some of these can be overwritten with generator specific content # https://cmake.org/cmake/help/v3.5/module/CPack.html -SET ( CPACK_PACKAGE_NAME "Hyperion" ) +SET ( CPACK_PACKAGE_NAME "Hyperion.NG" ) SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient light implementation" ) SET ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) -SET ( CPACK_PACKAGE_FILE_NAME "Hyperion-${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}") + +if ( NOT DEFINED DOCKER_PLATFORM ) + SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}") +else() + SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}-${DOCKER_PLATFORM}") +endif() + SET ( CPACK_PACKAGE_CONTACT "packages@hyperion-project.org") SET ( CPACK_PACKAGE_EXECUTABLES "hyperiond;Hyperion" ) SET ( CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icons/hyperion-icon-32px.png") diff --git a/test/jsonchecks/version.py b/test/jsonchecks/version.py new file mode 100644 index 00000000..4fb1f2a3 --- /dev/null +++ b/test/jsonchecks/version.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +import json, sys + +retval = 0 + +with open(sys.argv[1]) as f: + data = json.load(f) + sys.stdout.write(data['versionnr']) + sys.exit(0) diff --git a/version.json b/version.json index 356934a4..d84a7b78 100644 --- a/version.json +++ b/version.json @@ -1,21 +1,6 @@ -[ - { - "versionnr" : "2.1.0", - "versiondesc": "This version introduces feature x and some small bugfixes at the web configuration", - "versionchangelog":"https://www.hyperion-project.org/blog/id1", - "channel" : "Stable" - }, - { - "versionnr" : "2.0.1", - "versiondesc": "This is a bugfix release for 2.0.0", - "versionchangelog": "https://www.hyperion-project.org/blog/id3", - "channel" : "Stable" - }, - { - "versionnr" : "2.0.0", - "versiondesc": "Version 2.0.0 introduces the succesor of Hyperion 1.0 with plenty new features to discover with a entire code rework and a highly extended JSON RPC!", - "versionchangelog": "https://www.hyperion-project.org/blog/id0", - "channel" : "Stable" - } -] - +{ + "versionnr": "1.0.0", + "versiondesc": "Hyperion.NG introduces the succesor of Hyperion 1.0 with plenty new features to discover with a entire code rework and a highly extended JSON RPC!", + "versionchangelog": "https://www.hyperion-project.org/blog/id0", + "channel": "Beta" +} From b2c63ff770f92eeaff8f34e94f041057270f7080 Mon Sep 17 00:00:00 2001 From: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Date: Sat, 22 Jun 2019 16:12:09 +0200 Subject: [PATCH 4/4] Pre-Release detection on Azure --- .azure.yml | 64 +++++++++++++++++--------------------- CMakeLists.txt | 28 +++++++++++------ HyperionConfig.h.in | 2 +- cmake/FindGitVersion.cmake | 3 +- cmake/packages.cmake | 4 +-- test/jsonchecks/version.py | 11 +++++-- 6 files changed, 59 insertions(+), 53 deletions(-) diff --git a/.azure.yml b/.azure.yml index f0f0e928..27bacf46 100644 --- a/.azure.yml +++ b/.azure.yml @@ -35,6 +35,14 @@ jobs: - checkout: self # represents the repo where the initial Pipelines YAML file was found submodules: recursive # set to 'recursive' to get submodules of submodules + # read channel tag in version.json + - task: oneLuckiDevJson2Variable@1 + inputs: + jsonFile: 'version.json' + shouldPrefixVariables: true + variablePrefix: 'json' + displayName: 'Read and generate pipeline variables' + # build process - bash: ./.ci/ci_build.sh displayName: 'Build $(dockerName)' @@ -43,15 +51,6 @@ jobs: DOCKER_NAME: $(dockerName) PLATFORM: $(platform) - # read version.json and generate pipeline variables - - task: oneLuckiDevJson2Variable@1 - inputs: - jsonFile: 'version.json' - shouldPrefixVariables: true - variablePrefix: 'json' - condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) - displayName: 'Read and generate pipeline variables' - # copy files - bash: 'cp -v deploy/Hyperion.NG-* $(Build.ArtifactStagingDirectory)' workingDirectory: '$(Build.SourcesDirectory)' @@ -66,10 +65,10 @@ jobs: condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) displayName: 'Publish deployables artifacts' - # assign latest tag variable - - bash: echo "##vso[task.setvariable variable=latestTag]$(git tag | tail -1)" - displayName: "Read latest tag" - condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + # set release to pre-release + - bash: echo '##vso[task.setvariable variable=preRelease;]true' + condition: and(succeeded(), contains(variables['json.channel'], 'beta'), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Mark beta as pre-release' # create or update github release - task: GithubRelease@0 @@ -79,14 +78,11 @@ jobs: action: edit target: $(Build.SourceVersion) tagSource: manual - tag: '$(latestTag)' - title: '# $(latestTag) v$(json.versionnr)' - releaseNotesSource: input - releaseNotes: $(Build.SourceVersionMessage) + tag: $(Build.SourceBranchName) assets: '$(Build.ArtifactStagingDirectory)/*' assetUploadMode: 'replace' - isPreRelease: true addChangeLog: false + isPreRelease: $(preRelease) condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) displayName: Create/Update GitHub release @@ -103,6 +99,14 @@ jobs: - checkout: self # represents the repo where the initial Pipelines YAML file was found submodules: recursive # set to 'recursive' to get submodules of submodules + # read channel tag in version.json + - task: oneLuckiDevJson2Variable@1 + inputs: + jsonFile: 'version.json' + shouldPrefixVariables: true + variablePrefix: 'json' + displayName: 'Read and generate pipeline variables' + # install dependencies - bash: ./.ci/ci_install.sh displayName: 'Install dependencies' @@ -111,15 +115,6 @@ jobs: - bash: ./.ci/ci_build.sh displayName: 'Build macOS 10.13' - # read version.json and generate pipeline variables - - task: oneLuckiDevJson2Variable@1 - inputs: - jsonFile: 'version.json' - shouldPrefixVariables: true - variablePrefix: 'json' - condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) - displayName: 'Read and generate pipeline variables' - # copy files - bash: 'cp -v build/Hyperion.NG-* $(Build.ArtifactStagingDirectory)' workingDirectory: '$(Build.SourcesDirectory)' @@ -134,10 +129,10 @@ jobs: condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) displayName: 'Publish deployables artifacts' - # generate latest tag variable - - bash: echo "##vso[task.setvariable variable=latestTag]$(git tag | tail -1)" - displayName: "Read latest tag" - condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + # set release to pre-release + - bash: echo '##vso[task.setvariable variable=preRelease;]true' + condition: and(succeeded(), contains(variables['json.channel'], 'beta'), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) + displayName: 'Mark beta as pre-release' # create or update github release - task: GithubRelease@0 @@ -147,13 +142,10 @@ jobs: action: edit target: $(Build.SourceVersion) tagSource: manual - tag: '$(latestTag)' - title: '# $(latestTag) v$(json.versionnr)' - releaseNotesSource: input - releaseNotes: $(Build.SourceVersionMessage) + tag: '$(Build.SourceBranchName)' assets: '$(Build.ArtifactStagingDirectory)/*' assetUploadMode: 'replace' - isPreRelease: true addChangeLog: false + isPreRelease: $(preRelease) condition: and(succeeded(), ne(variables['system.pullrequest.isfork'], true), startsWith(variables['Build.SourceBranch'], 'refs/tags/')) displayName: Create/Update GitHub release diff --git a/CMakeLists.txt b/CMakeLists.txt index 3491ce62..46610df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,20 +25,28 @@ EXECUTE_PROCESS ( OUTPUT_VARIABLE RETURN_VERSION ) -SET(VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9_]+)?") -IF( ${RETURN_VERSION} MATCHES ${VERSION_REGEX} ) - STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_]+)" VERSION_PARTS ${RETURN_VERSION}) - LIST(GET VERSION_PARTS 0 VERSION_MAJOR) - LIST(GET VERSION_PARTS 1 VERSION_MINOR) - LIST(GET VERSION_PARTS 2 VERSION_PATCH) +SET( VERSION_REGEX "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z0-9_]+)?" ) +IF( ${RETURN_VERSION} MATCHES ${VERSION_REGEX}) + STRING(REGEX MATCHALL "[0-9]+|-([A-Za-z0-9_]+)" VERSION_PARTS ${RETURN_VERSION} ) + LIST( GET VERSION_PARTS 0 VERSION_MAJOR ) + LIST( GET VERSION_PARTS 1 VERSION_MINOR ) + LIST( GET VERSION_PARTS 2 VERSION_PATCH ) ELSE( ${RETURN_VERSION} MATCHES ${VERSION_REGEX} ) message( FATAL_ERROR "Failed to parse version.json string properly. Expect X.Y.Z.") ENDIF() -SET ( HYPERION_VERSION_STABLE OFF ) -SET ( HYPERION_VERSION_MAJOR ${VERSION_MAJOR} ) -SET ( HYPERION_VERSION_MINOR ${VERSION_MINOR} ) -SET ( HYPERION_VERSION_PATCH ${VERSION_PATCH} ) +SET( HYPERION_VERSION_MAJOR ${VERSION_MAJOR} ) +SET( HYPERION_VERSION_MINOR ${VERSION_MINOR} ) +SET( HYPERION_VERSION_PATCH ${VERSION_PATCH} ) + +# Read channel from version.json +EXECUTE_PROCESS ( + COMMAND python test/jsonchecks/version.py ${PROJECT_SOURCE_DIR}/version.json "channel" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE RETURN_CHANNEL +) + +SET ( HYPERION_VERSION_CHANNEL ${RETURN_CHANNEL} ) # Set build variables SET ( DEFAULT_AMLOGIC OFF ) diff --git a/HyperionConfig.h.in b/HyperionConfig.h.in index ddb8874e..b121c88a 100644 --- a/HyperionConfig.h.in +++ b/HyperionConfig.h.in @@ -42,6 +42,6 @@ #define HYPERION_VERSION_MAJOR "${HYPERION_VERSION_MAJOR}" #define HYPERION_VERSION_MINOR "${HYPERION_VERSION_MINOR}" #define HYPERION_VERSION_PATCH "${HYPERION_VERSION_PATCH}" -#define HYPERION_VERSION "${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}" +#define HYPERION_VERSION "${HYPERION_VERSION_CHANNEL}.${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}" #define HYPERION_JSON_VERSION "1.0.0" diff --git a/cmake/FindGitVersion.cmake b/cmake/FindGitVersion.cmake index b48f70ca..1cb1a7d0 100644 --- a/cmake/FindGitVersion.cmake +++ b/cmake/FindGitVersion.cmake @@ -7,4 +7,5 @@ STRING ( STRIP "${BUILD_ID}" BUILD_ID ) STRING ( STRIP "${VERSION_ID}" VERSION_ID ) STRING ( STRIP "${GIT_REMOTE_PATH}" GIT_REMOTE_PATH ) SET ( HYPERION_BUILD_ID "${VERSION_ID} (${BUILD_ID}) Git Remote: ${GIT_REMOTE_PATH}" ) -message ( STATUS "Current Version: ${HYPERION_BUILD_ID}" ) +SET ( HYPERION_VERSION "${HYPERION_VERSION_CHANNEL}.${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}" ) +message ( STATUS "Current Version: ${HYPERION_VERSION} (${HYPERION_BUILD_ID})" ) diff --git a/cmake/packages.cmake b/cmake/packages.cmake index ffc0ac72..aaa25fe7 100644 --- a/cmake/packages.cmake +++ b/cmake/packages.cmake @@ -29,9 +29,9 @@ SET ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Hyperion is an open source ambient ligh SET ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" ) if ( NOT DEFINED DOCKER_PLATFORM ) - SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}") + SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_CHANNEL}.${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}") else() - SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}-${DOCKER_PLATFORM}") + SET ( CPACK_PACKAGE_FILE_NAME "Hyperion.NG-${HYPERION_VERSION_CHANNEL}.${HYPERION_VERSION_MAJOR}.${HYPERION_VERSION_MINOR}.${HYPERION_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}-${DOCKER_PLATFORM}") endif() SET ( CPACK_PACKAGE_CONTACT "packages@hyperion-project.org") diff --git a/test/jsonchecks/version.py b/test/jsonchecks/version.py index 4fb1f2a3..06f6e2a7 100644 --- a/test/jsonchecks/version.py +++ b/test/jsonchecks/version.py @@ -4,6 +4,11 @@ import json, sys retval = 0 with open(sys.argv[1]) as f: - data = json.load(f) - sys.stdout.write(data['versionnr']) - sys.exit(0) + if len(sys.argv) < 3: + data = json.load(f) + sys.stdout.write(data['versionnr']) + sys.exit(0) + else: + data = json.load(f) + sys.stdout.write(data['channel']) + sys.exit(0)