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] 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)