diff --git a/build.gradle b/build.gradle index d6ce6fd2d9..fc2f570819 100644 --- a/build.gradle +++ b/build.gradle @@ -26,18 +26,6 @@ plugins { id 'java-platform' } -// set build props -project.ext { - timestamp = new Date().format('yyyyMMddHHmmSS') - revision = "git rev-parse --short HEAD".execute().text.trim() - if (project.version.contains('-SNAPSHOT')) { - expandedVersion = project.version.replace('SNAPSHOT', timestamp) - expandedVersionWithDot = project.version.replace('-SNAPSHOT', ".${timestamp}") - } else { - expandedVersion = project.version - expandedVersionWithDot = project.version - } -} task('serve') { dependsOn ':scm-ui:yarn_install', ':scm-webapp:serve' @@ -134,3 +122,25 @@ subprojects { } } + +// set build props +project.ext { + timestamp = new Date().format('yyyyMMddHHmmSS') + revision = "git rev-parse --short HEAD".execute().text.trim() + if (project.version.contains('-SNAPSHOT')) { + expandedVersion = project.version.replace('SNAPSHOT', timestamp) + expandedVersionWithDot = project.version.replace('-SNAPSHOT', ".${timestamp}") + dockerRepository = 'docker.io/cloudogu/scm-manager' + String snapshotVersion = revision + def buildNumber = System.getenv('BUILD_NUMBER') + if (buildNumber != null) { + snapshotVersion += "-${buildNumber}" + } + dockerTag = version.replace('SNAPSHOT', snapshotVersion) + } else { + expandedVersion = project.version + expandedVersionWithDot = project.version + dockerRepository = 'docker.io/scmmanager/scm-manager' + dockerTag = version.replace('SNAPSHOT', snapshotVersion) + } +} diff --git a/scm-packaging/docker/build.gradle b/scm-packaging/docker/build.gradle index 23a5ab5f80..0b86570755 100644 --- a/scm-packaging/docker/build.gradle +++ b/scm-packaging/docker/build.gradle @@ -75,21 +75,15 @@ task distribution(type: DockerBuildImage) { def images() { def version = project.version if (version.contains('-SNAPSHOT')) { - String snapshotVersion = revision - def buildNumber = System.getenv("BUILD_NUMBER") - if (buildNumber != null) { - snapshotVersion += "-${buildNumber}" - } - version = version.replace("SNAPSHOT", snapshotVersion) return [ - "docker.io/cloudogu/scm-manager:${version}" + "${dockerRepository}:${dockerTag}" ] } else { // What about patch releases? // It is a good idea to push always latest return [ - "docker.io/scmmanager/scm-manager:${version}", - 'docker.io/scmmanager/scm-manager:latest' + "${dockerRepository}:${dockerTag}", + "${dockerRepository}:latest" ] } } diff --git a/scm-packaging/docker/src/main/fs/etc/scm/server-config.xml b/scm-packaging/docker/src/main/fs/etc/scm/server-config.xml index 217e1ae052..09407daab9 100644 --- a/scm-packaging/docker/src/main/fs/etc/scm/server-config.xml +++ b/scm-packaging/docker/src/main/fs/etc/scm/server-config.xml @@ -32,7 +32,7 @@ if you have to change something ensure you know what you are doing. For further information on configuration scm-server have a look at: - https://www.scm-manager.org/docs/${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.x/en/administration/scm-server/ + https://www.scm-manager.org/docs/${version.major}.${version.minor}.x/en/administration/scm-server/ --> diff --git a/scm-packaging/helm/build.gradle b/scm-packaging/helm/build.gradle new file mode 100644 index 0000000000..898088a5bb --- /dev/null +++ b/scm-packaging/helm/build.gradle @@ -0,0 +1,59 @@ +/* + * MIT License + * + * Copyright (c) 2020-present Cloudogu GmbH and Contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +plugins { + id 'org.unbroken-dome.helm' version '1.4.0' +} + + +helm { + downloadClient { + enabled = true + version = '3.4.2' + } + charts { + scmServer { + chartName = "scm-manager" + chartVersion = expandedVersion + version = expandedVersion + + sourceDir = file('src/main/chart') + filtering { + enabled = true + values = [ + dockerRepository: dockerRepository, + dockerTag: dockerTag + ] + } + } + } +} + +helmPackageScmServerChart { + appVersion = expandedVersion +} + +task distribution { + dependsOn 'helmPackageScmServerChart' +} diff --git a/scm-packaging/helm/src/main/build/download.groovy b/scm-packaging/helm/src/main/build/download.groovy deleted file mode 100644 index bb4feeb1e2..0000000000 --- a/scm-packaging/helm/src/main/build/download.groovy +++ /dev/null @@ -1,65 +0,0 @@ -/** - * MIT License - * - * Copyright (c) 2020-present Cloudogu GmbH and Contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -private String getArchitecture() { - String architecture = System.getProperty("os.arch").toLowerCase(Locale.ENGLISH) - - if (architecture.equals("x86_64") || architecture.equals("amd64")) { - return "amd64" - } else if (architecture.equals("x86") || architecture.equals("i386")) { - return "386" - } else if (architecture.contains("arm64")) { - return "arm64" - } else if (architecture.equals("aarch32") || architecture.startsWith("arm")) { - return "arm" - } else if (architecture.contains("ppc64le") || (architecture.contains("ppc64") && System.getProperty("sun.cpu.endian").equals("little"))) { - return "ppc64le" - } - - throw new IllegalStateException("Unsupported architecture: ${architecture}") -} - -private String getExtension() { - String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) - if (osName.startsWith("windows")) { - return ".zip" - } - return "tar.gz" -} - -private String getOperatingSystem() { - String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH) - if (osName.startsWith("linux")) { - return "linux" - } else if (osName.startsWith("mac") || osName.startsWith("darwin")) { - return "darwin" - } else if (osName.startsWith("windows")) { - return "windows" - } - throw new IllegalStateException("Unsupported operating system: ${osName}") -} - -project.properties.setProperty("helm.os", getOperatingSystem()) -project.properties.setProperty("helm.arch", getArchitecture()) -project.properties.setProperty("helm.ext", getExtension()) diff --git a/scm-packaging/helm/src/main/chart/Chart.yaml b/scm-packaging/helm/src/main/chart/Chart.yaml index 1b98a56cef..d88ca88f11 100644 --- a/scm-packaging/helm/src/main/chart/Chart.yaml +++ b/scm-packaging/helm/src/main/chart/Chart.yaml @@ -1,29 +1,4 @@ -# -# MIT License -# -# Copyright (c) 2020-present Cloudogu GmbH and Contributors -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - apiVersion: v1 -appVersion: "1.0" name: scm-manager version: 0.1.0 description: The easiest way to share and manage your Git, Mercurial and Subversion repositories diff --git a/scm-packaging/helm/src/main/chart/values.yaml b/scm-packaging/helm/src/main/chart/values.yaml index 8f8252dbfb..a7a3a99ca2 100644 --- a/scm-packaging/helm/src/main/chart/values.yaml +++ b/scm-packaging/helm/src/main/chart/values.yaml @@ -28,9 +28,9 @@ image: # image.repository -- Name of SCM-Manager image - repository: ${docker.repository} + repository: ${dockerRepository} # image.tag -- Tag of SCM-Manager image - tag: ${docker.tag} + tag: ${dockerTag} # image.pullPolicy -- SCM-Manager image pull policy pullPolicy: IfNotPresent diff --git a/settings.gradle b/settings.gradle index fdaa56e6b5..71410e0d8a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -43,5 +43,6 @@ include 'scm-packaging:windows' include 'scm-packaging:deb' include 'scm-packaging:rpm' include 'scm-packaging:docker' +include 'scm-packaging:helm' includeBuild '../gradle-smp-plugin'