rombert commented on code in PR #32: URL: https://github.com/apache/sling-org-apache-sling-committer-cli/pull/32#discussion_r3571661473
########## src/main/java/org/apache/sling/cli/impl/release/UpdateDistCommand.java: ########## @@ -0,0 +1,303 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.cli.impl.release; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + +import org.apache.sling.cli.impl.Command; +import org.apache.sling.cli.impl.Credentials; +import org.apache.sling.cli.impl.CredentialsService; +import org.apache.sling.cli.impl.InputOption; +import org.apache.sling.cli.impl.UserInput; +import org.apache.sling.cli.impl.nexus.Artifact; +import org.apache.sling.cli.impl.nexus.LocalRepository; +import org.apache.sling.cli.impl.nexus.RepositoryService; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tmatesoft.svn.core.SVNCommitInfo; +import org.tmatesoft.svn.core.SVNDirEntry; +import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.BasicAuthenticationManager; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.io.ISVNEditor; +import org.tmatesoft.svn.core.io.SVNRepository; +import org.tmatesoft.svn.core.io.SVNRepositoryFactory; +import org.tmatesoft.svn.core.io.diff.SVNDeltaGenerator; +import picocli.CommandLine; + +/** + * Publishes a release's staged artifacts to {@code dist/release/sling} on dist.apache.org and removes + * the previous release, using SVNKit's pure-Java Subversion client over https. + * + * <p>This follows the flow used for Maven-based Sling module releases (see the Sling release management + * guide): the artifacts are downloaded from the Nexus staging repository and committed to + * {@code dist/release/sling}. Unlike the Sling IDE tooling, Maven releases never stage to + * {@code dist/dev}. Requires PMC membership to commit to dist.apache.org. + */ +@Component( + service = Command.class, + property = { + Command.PROPERTY_NAME_COMMAND_GROUP + "=" + UpdateDistCommand.GROUP, + Command.PROPERTY_NAME_COMMAND_NAME + "=" + UpdateDistCommand.NAME + }) [email protected]( + name = UpdateDistCommand.NAME, + description = "Publishes a release's staged artifacts to dist/release on dist.apache.org and removes the" + + " previous release. Requires PMC membership.", + subcommands = CommandLine.HelpCommand.class) +public class UpdateDistCommand implements Command { + + static final String GROUP = "release"; + static final String NAME = "update-dist"; + + static final String DIST_RELEASE_URL = "https://dist.apache.org/repos/dist/release/sling/"; + + static { + // register the http(s):// DAV repository factory used by all SVNKit operations below + DAVRepositoryFactory.setup(); + } + + private static final Logger LOGGER = LoggerFactory.getLogger(UpdateDistCommand.class); + + @CommandLine.Option( + names = {"-r", "--repository"}, + description = "Nexus staging repository id", + required = true) + private Integer repositoryId; + + @CommandLine.Option( Review Comment: I think this is a bit dangerous. We have releases where we have multiple release streams, e.g. resourceresolver 1.x and 2.x . I think the logic should be 'the closest oldest version', e.g. - existing: 1.2.4 , 2.0.2 - new: 2.0.4 Then we would add 2.0.4 and remove 2.0.2 . -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
