diff --git a/Jenkinsfile b/Jenkinsfile index dce718bbcd..e424e62f95 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -104,6 +104,11 @@ node('docker') { credentialsId: 'hub.docker.com-cesmarvin' ]) + mvn.useRepositoryCredentials([ + id: 'github.com/scm-manager/website', + credentialsId: 'cesmarvin-github' + ]) + // deploy java artifacts mvn.useDeploymentRepository([ id: 'packages.scm-manager.org', diff --git a/scm-packaging/deb/pom.xml b/scm-packaging/deb/pom.xml index fb702d8efa..c899a9c224 100644 --- a/scm-packaging/deb/pom.xml +++ b/scm-packaging/deb/pom.xml @@ -309,6 +309,18 @@ + + add-package-yml + package + + execute + + + + + + + set-repo-suffix deploy diff --git a/scm-packaging/deb/src/main/build/packageYaml.groovy b/scm-packaging/deb/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..5cef96eaeb --- /dev/null +++ b/scm-packaging/deb/src/main/build/packageYaml.groovy @@ -0,0 +1,26 @@ +/** + * 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. + */ + +def file = new File(project.build.directory, "package.yml") +file << "type: debian\n" diff --git a/scm-packaging/docker/pom.xml b/scm-packaging/docker/pom.xml index 9d745dbacf..0d566a5421 100644 --- a/scm-packaging/docker/pom.xml +++ b/scm-packaging/docker/pom.xml @@ -197,6 +197,18 @@ + + add-package-yml + package + + execute + + + + + + + diff --git a/scm-packaging/docker/src/main/build/packageYaml.groovy b/scm-packaging/docker/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..056008e386 --- /dev/null +++ b/scm-packaging/docker/src/main/build/packageYaml.groovy @@ -0,0 +1,26 @@ +/** + * 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. + */ + +def file = new File(project.build.directory, "package.yml") +file << "type: docker\n" diff --git a/scm-packaging/helm/pom.xml b/scm-packaging/helm/pom.xml index e06a0e7e0d..42b9f30ed5 100644 --- a/scm-packaging/helm/pom.xml +++ b/scm-packaging/helm/pom.xml @@ -81,7 +81,7 @@ - add-helm-url + init-helm-environment validate execute @@ -94,6 +94,18 @@ + + add-package-yml + package + + execute + + + + + + + diff --git a/scm-packaging/helm/src/main/build/packageYaml.groovy b/scm-packaging/helm/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..8338e52926 --- /dev/null +++ b/scm-packaging/helm/src/main/build/packageYaml.groovy @@ -0,0 +1,26 @@ +/** + * 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. + */ + +def file = new File(project.build.directory, "package.yml") +file << "type: helm\n" diff --git a/scm-packaging/pom.xml b/scm-packaging/pom.xml index 148815da97..42b77b97a3 100644 --- a/scm-packaging/pom.xml +++ b/scm-packaging/pom.xml @@ -55,6 +55,7 @@ rpm docker helm + release-yaml diff --git a/scm-packaging/release-yaml/pom.xml b/scm-packaging/release-yaml/pom.xml new file mode 100644 index 0000000000..850202281a --- /dev/null +++ b/scm-packaging/release-yaml/pom.xml @@ -0,0 +1,108 @@ + + + + + 4.0.0 + + + sonia.scm.packaging + scm-packaging + 2.0.0-SNAPSHOT + + + release-yaml + pom + 2.0.0-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + true + + + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.9.0 + + + org.codehaus.groovy + groovy-all + 3.0.3 + pom + runtime + + + org.yaml + snakeyaml + 1.21 + + + sonia.jgit + org.eclipse.jgit + ${jgit.version} + + + + + add-release-yml + package + + execute + + + + + + + + + deploy-release-yml + deploy + + execute + + + + + + + + + + + + + + diff --git a/scm-packaging/release-yaml/src/main/build/deploy.groovy b/scm-packaging/release-yaml/src/main/build/deploy.groovy new file mode 100644 index 0000000000..d4b1a88cc5 --- /dev/null +++ b/scm-packaging/release-yaml/src/main/build/deploy.groovy @@ -0,0 +1,65 @@ +/** + * 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. + */ + +import org.eclipse.jgit.api.Git +import org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider + +def getCredentials() { + def decrypter = session.lookup("org.apache.maven.settings.crypto.SettingsDecrypter") + def server = session.settings.getServer("github.com/scm-manager/website") + def result = decrypter.decrypt(new DefaultSettingsDecryptionRequest(server)) + return result.server +} + +if (project.version.contains("-SNAPSHOT")) { + println "we do not deploy snapshot releases" + return +} + +File websiteDir = new File(project.build.directory, "website") +websiteDir.deleteDir() + +Git git = Git.cloneRepository() + .setURI("https://github.com/scm-manager/website.git") + .setDirectory(websiteDir) + .setBranch("refs/heads/master") + .call() + +String targetPath = "content/releases/" + project.version.replace('.', "-") + ".yml" + +File source = new File(project.build.directory, "release.yml") +File target = new File(websiteDir, targetPath) +target << source.text + +git.add().addFilepattern(targetPath).call() +git.commit() + .setAuthor("CES Marvin", "cesmarvin@cloudogu.com") + .setMessage("add release descriptor for ${project.version}") + .call() + +def credentials = getCredentials() +git.push() + .setCredentialsProvider(new UsernamePasswordCredentialsProvider(credentials.username, credentials.password)) + .call() diff --git a/scm-packaging/release-yaml/src/main/build/releaseYaml.groovy b/scm-packaging/release-yaml/src/main/build/releaseYaml.groovy new file mode 100644 index 0000000000..c38fc16713 --- /dev/null +++ b/scm-packaging/release-yaml/src/main/build/releaseYaml.groovy @@ -0,0 +1,55 @@ +/** + * 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. + */ + +import groovy.io.FileType +import org.yaml.snakeyaml.Yaml +import java.text.SimpleDateFormat + +Yaml yaml = new Yaml(); + +def release = [:] +release.tag = project.version +SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") +sdf.setTimeZone(TimeZone.getTimeZone("UTC")) +release.date = sdf.format(new Date()) +release.packages = [] + +def moduleDirectory = project.basedir.getParentFile() +moduleDirectory.eachFile FileType.DIRECTORIES, { + def packageFile = new File(it, "target/package.yml") + if (packageFile.exists()) { + packageFile.withReader { r -> + def pkg = yaml.load(r) + release.packages.add(pkg) + } + } +} + +def buildir = new File(project.build.directory) +if (!buildir.exists()) { + buildir.mkdirs() +} + +def file = new File(buildir, "release.yml") +file << yaml.dump(release) diff --git a/scm-packaging/rpm/pom.xml b/scm-packaging/rpm/pom.xml index af39c996d3..40dc811467 100644 --- a/scm-packaging/rpm/pom.xml +++ b/scm-packaging/rpm/pom.xml @@ -343,6 +343,18 @@ + + add-package-yml + package + + execute + + + + + + + set-repo-suffix deploy diff --git a/scm-packaging/rpm/src/main/build/packageYaml.groovy b/scm-packaging/rpm/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..1e1e493296 --- /dev/null +++ b/scm-packaging/rpm/src/main/build/packageYaml.groovy @@ -0,0 +1,26 @@ +/** + * 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. + */ + +def file = new File(project.build.directory, "package.yml") +file << "type: redhat\n" diff --git a/scm-packaging/unix/pom.xml b/scm-packaging/unix/pom.xml index a0d5131941..e82b1d3676 100644 --- a/scm-packaging/unix/pom.xml +++ b/scm-packaging/unix/pom.xml @@ -109,6 +109,41 @@ + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.9.0 + + + org.codehaus.groovy + groovy-all + 3.0.3 + pom + runtime + + + com.google.guava + guava + 29.0-jre + + + + + add-package-yml + package + + execute + + + + + + + + + + diff --git a/scm-packaging/unix/src/main/build/packageYaml.groovy b/scm-packaging/unix/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..8defc88027 --- /dev/null +++ b/scm-packaging/unix/src/main/build/packageYaml.groovy @@ -0,0 +1,39 @@ +/** + * 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. + */ + +import com.google.common.hash.* +import com.google.common.io.Files + +def packageFile = project.attachedArtifacts.find(it -> it.file.name.endsWith("tar.gz")).file +def repository = project.version.contains("-SNAPSHOT") ? "snapshots" : "releases" + +HashCode hashCode = Files.asByteSource(packageFile).hash(Hashing.sha256()) +def deploymentTarget = project.properties.getProperty("deployment.target") + +def file = new File(project.build.directory, "package.yml") +file << """ +type: unix +checksum: ${hashCode} +url: ${deploymentTarget}/${repository}/releases/sonia/scm/packaging/unix/${project.version}/${packageFile.name} +""" diff --git a/scm-packaging/windows/pom.xml b/scm-packaging/windows/pom.xml index b80eddaf8d..956ccba075 100644 --- a/scm-packaging/windows/pom.xml +++ b/scm-packaging/windows/pom.xml @@ -99,6 +99,40 @@ + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.9.0 + + + org.codehaus.groovy + groovy-all + 3.0.3 + pom + runtime + + + com.google.guava + guava + 29.0-jre + + + + + add-package-yml + package + + execute + + + + + + + + + + diff --git a/scm-packaging/windows/src/main/build/packageYaml.groovy b/scm-packaging/windows/src/main/build/packageYaml.groovy new file mode 100644 index 0000000000..f5f029f746 --- /dev/null +++ b/scm-packaging/windows/src/main/build/packageYaml.groovy @@ -0,0 +1,39 @@ +/** + * 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. + */ + +import com.google.common.hash.* +import com.google.common.io.Files + +def packageFile = project.attachedArtifacts.find(it -> it.file.name.endsWith("zip")).file +def repository = project.version.contains("-SNAPSHOT") ? "snapshots" : "releases" + +HashCode hashCode = Files.asByteSource(packageFile).hash(Hashing.sha256()) +def deploymentTarget = project.properties.getProperty("deployment.target") + +def file = new File(project.build.directory, "package.yml") +file << """ +type: windows +checksum: ${hashCode} +url: ${deploymentTarget}/${repository}/releases/sonia/scm/packaging/unix/${project.version}/${packageFile.name} +"""