diff --git a/.github/actions/build-number/action.yml b/.github/actions/build-number/action.yml new file mode 100644 index 000000000..30a93ec1f --- /dev/null +++ b/.github/actions/build-number/action.yml @@ -0,0 +1,10 @@ +name: 'Generate next build number' +description: 'Generate next build number' + +outputs: + build-number: + description: 'Generated build number' + +runs: + using: 'node12' + main: 'build-number.js' \ No newline at end of file diff --git a/.github/actions/build-number/build-number.js b/.github/actions/build-number/build-number.js new file mode 100644 index 000000000..00ef02f6d --- /dev/null +++ b/.github/actions/build-number/build-number.js @@ -0,0 +1,172 @@ +const core = require('@actions/core'); +const fs = require('fs'); + +function VersionPart(part) { + var self = this; + var m_prefix = ''; + var m_suffix = ''; + var m_number = 0; + + self.setNumber = function(number) { + if (!isNaN(number)) { + m_number = number; + } + } + + self.getNumber = function() { + return m_number; + } + + self.toString = function() { + return m_prefix + m_number.toString() + m_suffix; + } + + self.next = function() { + m_number += 1; + } + + function parsePartPrefix(part) { + if (isNaN(part[0])) { + for (var i = 0; i < part.length; ++i) { + if (!isNaN(part[i])) { + break; + } + m_prefix += part[i]; + } + } + } + + function parsePartNumber(part) { + let number = 0; + + if (m_prefix.length > 0){ + number = parseInt(part.substring(m_prefix.length)); + } + else{ + number = parseInt(part); + } + + self.setNumber(number); + } + + function parsePartSuffix(part) { + let items = part.split('-'); + if (items.length == 2) { + m_suffix = '-' + items[1]; + } + } + + self.setPart = function(part) { + if (part && part.length > 0){ + parsePartPrefix(part); + parsePartNumber(part); + parsePartSuffix(part); + } + } + + self.setPart(part); +} + +function Version(version) { + const PARTS_DELIMITER = '.'; + var m_major = new VersionPart(); + var m_minor = new VersionPart(); + var m_patch = new VersionPart(); + var m_build = new VersionPart(); + + this.toString = function() { + return ( m_major.toString() + PARTS_DELIMITER + + m_minor.toString() + PARTS_DELIMITER + + m_patch.toString() + PARTS_DELIMITER + + m_build.toString()); + } + + this.nextBuild = function() { + m_build.next(); + } + + function init() { + let versionParts = version.split(PARTS_DELIMITER); + + if (versionParts.length == 3) { + m_major.setPart(versionParts[0]); + m_minor.setPart(versionParts[1]); + m_build.setPart(versionParts[2]); + m_patch.setNumber(m_build.getNumber()); + } + else if (versionParts.length == 4) { + m_major.setPart(versionParts[0]); + m_minor.setPart(versionParts[1]); + m_patch.setPart(versionParts[2]); + m_build.setPart(versionParts[3]); + } + else { + core.setFailed('ERROR: previous-build contains wrong version number <' + version + '>'); + } + } + + this.getMajor = function() { + return m_major.getNumber(); + } + + this.getMinor = function() { + return m_minor.getNumber(); + } + + this.getPatch = function() { + return m_patch.getNumber(); + } + + this.isSamePatch = function(version) { + return (m_major.getNumber() == version.getMajor() && + m_minor.getNumber() == version.getMinor() && + m_patch.getNumber() == version.getPatch()); + } + + init(); +} + +function getOptionValue(source, option) { + let start = source.indexOf(option); + if (start != -1) { + start += option.length + 1; + let end = source.indexOf(')', start); + return source.toString('utf8', start, end).replace(/\"/g, '').trim(); + } + else{ + core.setFailed("ERROR: Can't find option <" + option + ">"); + } +} + +function getVersionFromFile(){ + let options = fs.readFileSync('cmake/Version.cmake'); + let major = getOptionValue(options, 'SYNERGY_VERSION_MAJOR'); + let minor = getOptionValue(options, 'SYNERGY_VERSION_MINOR'); + let patch = getOptionValue(options, 'SYNERGY_VERSION_PATCH'); + let stage = getOptionValue(options, 'SYNERGY_VERSION_STAGE'); + + return (major + '.' + minor + '.' + patch + '-' + stage); +} + +try { + let version = null; + let gitVersion = new Version(core.getInput('previous-build')); + let cmakeVersion = new Version(getVersionFromFile()); + + console.log('INFO: Version from Git: <' + gitVersion.toString() + '>'); + console.log('INFO: Version from cmake: <' + cmakeVersion.toString() + '>'); + + if (cmakeVersion.isSamePatch(gitVersion)) { + gitVersion.nextBuild(); + version = gitVersion; + } + else { + version = cmakeVersion; + } + + console.log('INFO: Generate build version: <' + version.toString() + '>'); + core.setOutput('next-build', version.toString()); + + } catch (error) { + core.setFailed(error.message); + } \ No newline at end of file diff --git a/.github/workflows/create-build.yml b/.github/workflows/create-build.yml new file mode 100644 index 000000000..1660876ac --- /dev/null +++ b/.github/workflows/create-build.yml @@ -0,0 +1,45 @@ +name: Create Build + +on: + push: + branches: [ master ] + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: 'Get Previous tag' + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@master" + + - name: 'Install git core' + run: npm install @actions/core + + - name: 'Generate next build number' + id: build + uses: "./.github/actions/build-number" + with: + previous-build: ${{ steps.previoustag.outputs.tag }} + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.build.outputs.next-build }} + release_name: Version ${{ steps.build.outputs.next-build }} + commitish: master + draft: false + prerelease: true + + - name: Run build on Azure + uses: Azure/pipelines@v1 + with: + azure-devops-project-url: 'https://dev.azure.com/symless/synergy-core' + azure-pipeline-name: 'symless.synergy-core' + azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}' \ No newline at end of file diff --git a/CI/Linux/linux-build.yml b/CI/Linux/linux-build.yml index cc7f1fccd..401c87d30 100644 --- a/CI/Linux/linux-build.yml +++ b/CI/Linux/linux-build.yml @@ -1,4 +1,8 @@ steps: + - script: | + python3 CI/build_version.py + displayName: 'Update Version.cmake' + - script: | mkdir build-release cd build-release @@ -56,6 +60,7 @@ steps: SYNERGY_REVISION=`git rev-parse --short=8 HEAD` SYNERGY_DEB_VERSION="${SYNERGY_VERSION}.${SYNERGY_VERSION_STAGE}~b$(Build.BuildNumber)+${SYNERGY_REVISION}" SYNERGY_RPM_VERSION="${SYNERGY_VERSION}-$(Build.BuildNumber).${SYNERGY_VERSION_STAGE}.${SYNERGY_REVISION}" + echo "##vso[task.setvariable variable=SYNERGY_VERSION_BUILD]${SYNERGY_VERSION_BUILD}" echo "##vso[task.setvariable variable=SYNERGY_VERSION_STAGE]${SYNERGY_VERSION_STAGE}" echo "##vso[task.setvariable variable=SYNERGY_VERSION]${SYNERGY_VERSION}" echo "##vso[task.setvariable variable=SYNERGY_REVISION]${SYNERGY_REVISION}" @@ -145,7 +150,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: './standard_package' contents: '*' - targetFolder: 'synergy-core/v1-core-standard/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-standard/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send standard Package to sandor' condition: eq(variables['Build.Reason'], 'Manual') @@ -155,7 +160,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: './enterprise_package' contents: '*' - targetFolder: 'synergy-core/v1-core-enterprise/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-enterprise/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send enterprise Package to sandor' condition: eq(variables['Build.Reason'], 'Manual') \ No newline at end of file diff --git a/CI/MacOS/mac-build.yml b/CI/MacOS/mac-build.yml index f8e54677c..cb774d528 100644 --- a/CI/MacOS/mac-build.yml +++ b/CI/MacOS/mac-build.yml @@ -6,6 +6,12 @@ steps: keychain: 'temp' condition: eq(variables['Build.Reason'], 'Manual') + - task: CmdLine@2 + inputs: + script: | + python3 CI/build_version.py + displayName: 'Update Version.cmake' + - task: CmdLine@2 inputs: script: | @@ -74,6 +80,7 @@ steps: SYNERGY_DMG_VERSION="${SYNERGY_VERSION}-${SYNERGY_VERSION_STAGE}_b$(Build.BuildNumber)-${SYNERGY_REVISION}" SYNERGY_DMG_FILENAME=$(prefix)_v${SYNERGY_DMG_VERSION}_macos_$(platform).dmg echo "##vso[task.setvariable variable=SYNERGY_VERSION_STAGE]${SYNERGY_VERSION_STAGE}" + echo "##vso[task.setvariable variable=SYNERGY_VERSION_BUILD]${SYNERGY_VERSION_BUILD}" echo "##vso[task.setvariable variable=SYNERGY_VERSION]${SYNERGY_VERSION}" echo "##vso[task.setvariable variable=SYNERGY_REVISION]${SYNERGY_REVISION}" echo "##vso[task.setvariable variable=SYNERGY_DMG_VERSION]${SYNERGY_DMG_VERSION}" @@ -114,7 +121,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: '$(Build.Repository.LocalPath)/pkg' contents: '*' - targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send Package to sandor' condition: eq(variables['Build.Reason'], 'Manual') diff --git a/CI/Windows/windows-build.yml b/CI/Windows/windows-build.yml index 01591abe4..fbe0995ab 100644 --- a/CI/Windows/windows-build.yml +++ b/CI/Windows/windows-build.yml @@ -15,6 +15,10 @@ steps: architecture: 'x64' displayName: 'Set python version' + - script: | + python3 CI/build_version.py + displayName: 'Update Version.cmake' + - script: | cd $(Build.SourcesDirectory) python -m pip install aqtinstall @@ -170,6 +174,7 @@ steps: set SYNERGY_VERSION=%SYNERGY_VERSION_MAJOR%.%SYNERGY_VERSION_MINOR%.%SYNERGY_VERSION_PATCH% git rev-parse --short=8 HEAD > gitversion set /p SYNERGY_REVISION= < gitversion + echo ##vso[task.setvariable variable=SYNERGY_VERSION_BUILD]%SYNERGY_VERSION_BUILD% echo ##vso[task.setvariable variable=SYNERGY_VERSION_STAGE]%SYNERGY_VERSION_STAGE% echo ##vso[task.setvariable variable=SYNERGY_VERSION]%SYNERGY_VERSION% echo ##vso[task.setvariable variable=SYNERGY_REVISION]%SYNERGY_REVISION% @@ -197,7 +202,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: '$(Build.ArtifactStagingDirectory)/' contents: '*.zip' - targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send archives to sandor' condition: eq(variables['Build.SourceBranch'], 'refs/heads/master') @@ -207,7 +212,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: '$(Build.Repository.LocalPath)\build32\installer\bin\Release\' contents: '*' - targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send x86 Package to sandor' condition: eq(variables['Build.Reason'], 'Manual') @@ -217,7 +222,7 @@ steps: sshEndpoint: 'Azure on Sandor' sourceFolder: '$(Build.Repository.LocalPath)\build64\installer\bin\Release\' contents: '*' - targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/$(SYNERGY_REVISION)/' + targetFolder: 'synergy-core/v1-core-$(buildType)/$(SYNERGY_VERSION)/$(SYNERGY_VERSION_STAGE)/b$(SYNERGY_VERSION_BUILD)-$(SYNERGY_REVISION)/' readyTimeout: '20000' displayName: 'Send x64 Package to sandor' condition: eq(variables['Build.Reason'], 'Manual') diff --git a/CI/build_version.py b/CI/build_version.py new file mode 100644 index 000000000..b3855271c --- /dev/null +++ b/CI/build_version.py @@ -0,0 +1,109 @@ +import subprocess + +class VersionPart: + + def __init__(self, part = ''): + self.prefix = '' + self.suffix = '' + self.number = 0 + + if part: + self.__parsePreffix(part) + self.__parseNumber(part) + self.__parseSuffix(part) + + def __parsePreffix(self, part): + if not part[0].isdigit(): + for i in part: + if not i.isdigit(): + self.prefix += i + else: + break + + def __parseNumber(self, part): + start = len(self.prefix) + end = part.find('-') + if end > 0: + self.number = int(part[start:end]) + else: + self.number = int(part[start:]) + + def __parseSuffix(self, part): + items = part.split('-') + if len(items) == 2: + self.suffix = '-' + items[1] + + def __str__(self): + return self.prefix + str(self.number) + self.suffix + +class Version: + + def __init__(self, version): + versionParts = version.split('.') + + if len(versionParts) == 3: + self.major = VersionPart(versionParts[0]) + self.minor = VersionPart(versionParts[1]) + self.build = VersionPart(versionParts[2]) + self.patch = VersionPart() + self.patch.number = self.build.number + elif len(versionParts) == 4: + self.major = VersionPart(versionParts[0]) + self.minor = VersionPart(versionParts[1]) + self.patch = VersionPart(versionParts[2]) + self.build = VersionPart(versionParts[3]) + else: + print('ERROR: Wrong version number') + + def __str__(self): + result = str(self.major) + '.' + result += str(self.minor) + '.' + result += str(self.patch) + '.' + result += str(self.build) + return result + + def nextBuild(self): + self.build.number += 1 + +class VersionFile: + def __init__(self, file): + self.file = file + + def setOption(self, name, value): + fp = open(self.file, 'rt+') + content = '' + for line in fp: + print(line) + if line.find(name) != -1: + line = 'set ('+ name + ' ' + value + ')' + content += line + fp.write(content) + fp.close() + + +def getVesionFromGit(): + cmd = ('git tag --sort=-creatordate').split() + + try: + proccess = subprocess.run(cmd, stdout=subprocess.PIPE, text=True) + versions = proccess.stdout.split() + print('INFO: Version '+ versions[0] + ' has been read from git') + return versions[0] + except subprocess.CalledProcessError: + print('ERROR: Unable to get version from git') + exit(1) + +def updateVersionFile(number): + fp = open('cmake/Version.cmake') + content = fp.read() + fp.close() + + fp = open('cmake/Version.cmake', 'wt') + fp.write(content.replace('set (SYNERGY_VERSION_BUILD 1)', 'set (SYNERGY_VERSION_BUILD ' + str(number) + ')')) + fp.close() + +if __name__ == '__main__': + version = Version(getVesionFromGit()) + version.nextBuild() + updateVersionFile(version.build.number) + print('INFO: Generate build number is: <' + str(version) + '>') \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d01f24c6..6fb199cc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,12 +391,14 @@ macro(generate_versionfile) "export SYNERGY_VERSION_MAJOR=\"${SYNERGY_VERSION_MAJOR}\"\n" "export SYNERGY_VERSION_MINOR=\"${SYNERGY_VERSION_MINOR}\"\n" "export SYNERGY_VERSION_PATCH=\"${SYNERGY_VERSION_PATCH}\"\n" + "export SYNERGY_VERSION_BUILD=\"${SYNERGY_VERSION_BUILD}\"\n" "export SYNERGY_VERSION_STAGE=\"${SYNERGY_VERSION_STAGE}\"\n") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") FILE(WRITE ${CMAKE_BINARY_DIR}/version.bat "SET SYNERGY_VERSION_MAJOR=${SYNERGY_VERSION_MAJOR}\n" "SET SYNERGY_VERSION_MINOR=${SYNERGY_VERSION_MINOR}\n" "SET SYNERGY_VERSION_PATCH=${SYNERGY_VERSION_PATCH}\n" + "SET SYNERGY_VERSION_BUILD=${SYNERGY_VERSION_BUILD}\n" "SET SYNERGY_VERSION_STAGE=${SYNERGY_VERSION_STAGE}\n") endif() endmacro(generate_versionfile) diff --git a/ChangeLog b/ChangeLog index f15834047..55c5a9f00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ Bug fixes: Enhancements: - #6867 Create only 1 artefact for macOS +- #6885 Make build for every merge to master v1.13.0-rc2 =========== diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ed6101b9d..462df977f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -69,13 +69,13 @@ jobs: catalina-std: image: macOS-10.15 platform: x86-64 - version: 10.14 + version: 10.15 buildType: "standard" prefix: "synergy" catalina-ent: image: macOS-10.15 platform: x86-64 - version: 10.14 + version: 10.15 buildType: "enterprise" prefix: "synergy-enterprise" pool: diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 130740c64..0347fbfc7 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -7,6 +7,7 @@ cmake_minimum_required (VERSION 3.4) set (SYNERGY_VERSION_MAJOR 1) set (SYNERGY_VERSION_MINOR 13) set (SYNERGY_VERSION_PATCH 0) +set (SYNERGY_VERSION_BUILD 1) set (SYNERGY_VERSION_STAGE "rc2") # @@ -53,20 +54,12 @@ else() endif() if (DEFINED ENV{BUILD_NUMBER}) - set (SYNERGY_BUILD_NUMBER $ENV{BUILD_NUMBER}) -else() - set (SYNERGY_BUILD_NUMBER 1) + set (SYNERGY_VERSION_BUILD $ENV{BUILD_NUMBER}) endif() string (TIMESTAMP SYNERGY_BUILD_DATE "%Y%m%d" UTC) set (SYNERGY_SNAPSHOT_INFO ".${SYNERGY_VERSION_STAGE}.${SYNERGY_REVISION}") - -if (SYNERGY_VERSION_STAGE STREQUAL "snapshot") - set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}.b${SYNERGY_BUILD_NUMBER}-${SYNERGY_REVISION}") -else() - set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}") -endif() - +set (SYNERGY_VERSION_TAG "${SYNERGY_VERSION_STAGE}.b${SYNERGY_VERSION_BUILD}-${SYNERGY_REVISION}") set (SYNERGY_VERSION "${SYNERGY_VERSION_MAJOR}.${SYNERGY_VERSION_MINOR}.${SYNERGY_VERSION_PATCH}") set (SYNERGY_VERSION_STRING "${SYNERGY_VERSION}-${SYNERGY_VERSION_TAG}") message (STATUS "Full Synergy version string is '" ${SYNERGY_VERSION_STRING} "'") @@ -75,7 +68,7 @@ add_definitions (-DSYNERGY_VERSION="${SYNERGY_VERSION}") add_definitions (-DSYNERGY_VERSION_STRING="${SYNERGY_VERSION_STRING}") add_definitions (-DSYNERGY_REVISION="${SYNERGY_REVISION}") add_definitions (-DSYNERGY_BUILD_DATE="${SYNERGY_BUILD_DATE}") -add_definitions (-DSYNERGY_BUILD_NUMBER=${SYNERGY_BUILD_NUMBER}) +add_definitions (-DSYNERGY_VERSION_BUILD=${SYNERGY_VERSION_BUILD}) if (SYNERGY_DEVELOPER_MODE) add_definitions (-DSYNERGY_DEVELOPER_MODE=1) diff --git a/dist/rpm/synergy.spec.in b/dist/rpm/synergy.spec.in index 7f1c1fe46..2ab17d766 100644 --- a/dist/rpm/synergy.spec.in +++ b/dist/rpm/synergy.spec.in @@ -7,7 +7,7 @@ Source: https://symless.com/synergy/downloads Vendor: Symless Packager: Symless License: GPLv2 -Release: @SYNERGY_BUILD_NUMBER@@SYNERGY_SNAPSHOT_INFO@%{?dist} +Release: @SYNERGY_VERSION_BUILD@@SYNERGY_SNAPSHOT_INFO@%{?dist} %description Synergy allows you to share one mouse and keyboard between multiple computers.