diff --git a/RELEASE.adoc b/RELEASE.adoc index bfa0567fcd..72695f0381 100644 --- a/RELEASE.adoc +++ b/RELEASE.adoc @@ -138,34 +138,19 @@ $ ./gradlew saganCreateRelease saganDeleteRelease -PgitHubAccessToken= - Replace with the milestone you are releasing now (i.e. 5.5.0-RC1) -* Generate the release notes - -.... -java -jar github-changelog-generator.jar \ - --changelog.repository=spring-projects/spring-security - --spring.config.location=scripts/release/release-notes-sections.yml \ - $MILESTONE release-notes -.... - -Note 1: `+$MILESTONE+` is something like `+5.2.1+` or `+5.3.0-M1+`. + -Note 2: The location `+scripts/release/release-notes-sections.yml+` is -relative to the `+spring-security+` repo. + -Note 3: This will create a file on your filesystem -called `+release-notes+`. +---- +$ ./gradlew generateChangelog -P +---- * Copy the release notes to your clipboard (your mileage may vary with the following command) .... -cat release-notes | xclip -selection clipboard +cat build/changelog/release-notes.md | xclip -selection clipboard .... * Create the diff --git a/build.gradle b/build.gradle index aa1b8d393a..e7afa7d363 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'org.springframework.security.update-dependencies' apply plugin: 'org.springframework.security.sagan' apply plugin: 'org.springframework.github.milestone' +apply plugin: 'org.springframework.github.changelog' group = 'org.springframework.security' description = 'Spring Security' diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a3190c148d..bf8c5d4674 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -52,6 +52,10 @@ gradlePlugin { id = "org.springframework.github.milestone" implementationClass = "org.springframework.gradle.github.milestones.GitHubMilestonePlugin" } + githubChangelog { + id = "org.springframework.github.changelog" + implementationClass = "org.springframework.gradle.github.changelog.GitHubChangelogPlugin" + } } } diff --git a/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java b/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java new file mode 100644 index 0000000000..2000e1a378 --- /dev/null +++ b/buildSrc/src/main/java/org/springframework/gradle/github/changelog/GitHubChangelogPlugin.java @@ -0,0 +1,102 @@ +/* + * Copyright 2019-2020 the original author or authors. + * + * Licensed 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 + * + * https://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.springframework.gradle.github.changelog; + +import org.gradle.api.Action; +import org.gradle.api.Plugin; +import org.gradle.api.Project; +import org.gradle.api.Task; +import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.DependencySet; +import org.gradle.api.artifacts.repositories.ExclusiveContentRepository; +import org.gradle.api.artifacts.repositories.InclusiveRepositoryContentDescriptor; +import org.gradle.api.artifacts.repositories.IvyArtifactRepository; +import org.gradle.api.artifacts.repositories.IvyPatternRepositoryLayout; +import org.gradle.api.tasks.JavaExec; + +import java.io.File; +import java.nio.file.Paths; + +public class GitHubChangelogPlugin implements Plugin { + + public static final String CHANGELOG_GENERATOR_CONFIGURATION_NAME = "changelogGenerator"; + + @Override + public void apply(Project project) { + createRepository(project); + createChangelogGeneratorConfiguration(project); + project.getTasks().register("generateChangelog", JavaExec.class, new Action() { + @Override + public void execute(JavaExec generateChangelog) { + File outputFile = project.file(Paths.get(project.getBuildDir().getPath(), "changelog/release-notes.md")); + outputFile.getParentFile().mkdirs(); + generateChangelog.setGroup("Release"); + generateChangelog.setDescription("Generates the changelog"); + generateChangelog.setWorkingDir(project.getRootDir()); + generateChangelog.classpath(project.getConfigurations().getAt(CHANGELOG_GENERATOR_CONFIGURATION_NAME)); + generateChangelog.doFirst(new Action() { + @Override + public void execute(Task task) { + generateChangelog.args("--spring.config.location=scripts/release/release-notes-sections.yml", project.property("nextVersion"), outputFile.toString()); + } + }); + } + }); + } + + private void createChangelogGeneratorConfiguration(Project project) { + project.getConfigurations().create(CHANGELOG_GENERATOR_CONFIGURATION_NAME, new Action() { + @Override + public void execute(Configuration configuration) { + configuration.defaultDependencies(new Action() { + @Override + public void execute(DependencySet dependencies) { + dependencies.add(project.getDependencies().create("spring-io:github-changelog-generator:0.0.6")); + } + }); + } + }); + } + + private void createRepository(Project project) { + IvyArtifactRepository repository = project.getRepositories().ivy(new Action() { + @Override + public void execute(IvyArtifactRepository repository) { + repository.setUrl("https://github.com/"); + repository.patternLayout(new Action() { + @Override + public void execute(IvyPatternRepositoryLayout layout) { + layout.artifact("[organization]/[artifact]/releases/download/v[revision]/[artifact].[ext]"); + } + }); + repository.getMetadataSources().artifact(); + } + }); + project.getRepositories().exclusiveContent(new Action() { + @Override + public void execute(ExclusiveContentRepository exclusiveContentRepository) { + exclusiveContentRepository.forRepositories(repository); + exclusiveContentRepository.filter(new Action() { + @Override + public void execute(InclusiveRepositoryContentDescriptor descriptor) { + descriptor.includeGroup("spring-io"); + } + }); + } + }); + } +}