-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull release notes from
keycloak-client
repository
Closes #547 Signed-off-by: Jon Koops <[email protected]>
- Loading branch information
Showing
154 changed files
with
205 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash -e | ||
|
||
VERSION=$1 | ||
if [ "$VERSION" == "" ]; then | ||
echo "usage: add-version-client.sh VERSION" | ||
exit 1 | ||
fi | ||
|
||
VERSION_NAME=`echo $VERSION | sed 's/.Final//' | sed 's/.CR[[:digit:]]//'` | ||
DATE=`date +%F` | ||
|
||
if [[ "$VERSION" == *".0" ]]; then | ||
TEMPLATE="version-template.json" | ||
else | ||
TEMPLATE="versions/keycloak-client/${VERSION%.*}.0.json" | ||
fi | ||
|
||
if [ ! -f "$TEMPLATE" ]; then | ||
echo "$TEMPLATE not found" | ||
exit | ||
fi | ||
|
||
cat $TEMPLATE | sed "s/\"version\":.*/\"version\": \"$VERSION\",/" | sed 's/"date": ".*"/"date": "DATE"/' | sed "s/DATE/$DATE/" > versions/keycloak-client/$VERSION_NAME.json | ||
|
||
CURRENT=`cat pom.xml | grep '<version.keycloak.client>' | cut -d '>' -f 2 | cut -d '<' -f 1` | ||
LATEST=`echo -e "$CURRENT\n$VERSION" | sort -V -r | head -n 1` | ||
|
||
sed -i "s|<version.keycloak.client>$CURRENT</version.keycloak.client>|<version.keycloak.client>$LATEST</version.keycloak.client>|g" pom.xml | ||
|
||
mvn install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
sources: | ||
- id: keycloak | ||
repo: keycloak/keycloak | ||
releaseNotes: release/${version.getVersionShorter()}/docs/documentation/release_notes/topics/${version.getVersion()?replace(".", "_")}.adoc | ||
attributeSources: | ||
- release/${version.getVersionShorter()}/docs/documentation/topics/templates/document-attributes.adoc | ||
- ${version.getVersion()}/docs/documentation/topics/templates/document-attributes.adoc | ||
- id: keycloak-client | ||
repo: keycloak/keycloak-client | ||
releaseNotes: main/docs/release-notes/${version.getVersion()?replace(".", "_")}.adoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/org/keycloak/webbuilder/ReleasesMetadata.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.keycloak.webbuilder; | ||
|
||
import java.util.List; | ||
|
||
public class ReleasesMetadata { | ||
public List<ReleaseSource> sources; | ||
|
||
public List<ReleaseSource> getSources() { | ||
return sources; | ||
} | ||
|
||
public void setSources(List<ReleaseSource> sources) { | ||
this.sources = sources; | ||
} | ||
|
||
public static class ReleaseSource { | ||
private String id; | ||
private String repo; | ||
private String releaseNotes; | ||
private List<String> attributeSources; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getRepo() { | ||
return repo; | ||
} | ||
|
||
public void setRepo(String repo) { | ||
this.repo = repo; | ||
} | ||
|
||
public String getReleaseNotes() { | ||
return releaseNotes; | ||
} | ||
|
||
public void setReleaseNotes(String releaseNotes) { | ||
this.releaseNotes = releaseNotes; | ||
} | ||
|
||
public List<String> getAttributeSources() { | ||
return attributeSources; | ||
} | ||
|
||
public void setAttributeSources(List<String> attributeSources) { | ||
this.attributeSources = attributeSources; | ||
} | ||
} | ||
} |
71 changes: 48 additions & 23 deletions
71
src/main/java/org/keycloak/webbuilder/builders/ReleaseNotesBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,98 @@ | ||
package org.keycloak.webbuilder.builders; | ||
|
||
import freemarker.template.Configuration; | ||
import freemarker.template.Template; | ||
import org.keycloak.webbuilder.ReleasesMetadata; | ||
import org.keycloak.webbuilder.Versions; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.net.URL; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ReleaseNotesBuilder extends AbstractBuilder { | ||
|
||
private static final String DOCUMENT_ATTRIBUTES_TAG_URL = "https://raw.githubusercontent.com/keycloak/keycloak/%s/docs/documentation/topics/templates/document-attributes.adoc"; | ||
private static final String DOCUMENT_ATTRIBUTES_BRANCH_URL = "https://raw.githubusercontent.com/keycloak/keycloak/release/%s/docs/documentation/topics/templates/document-attributes.adoc"; | ||
|
||
private static final String RELEASE_NOTES_URL = "https://raw.githubusercontent.com/keycloak/keycloak/release/%s/docs/documentation/release_notes/topics/%s.adoc"; | ||
|
||
@Override | ||
protected String getTitle() { | ||
return "Release Notes"; | ||
} | ||
|
||
public void build() throws IOException { | ||
File releasesCache = new File(context.getCacheDir(), "releases"); | ||
@Override | ||
protected void build() throws Exception { | ||
ReleasesMetadata metadata = context.getReleasesMetadata(); | ||
|
||
for (ReleasesMetadata.ReleaseSource source : metadata.getSources()) { | ||
buildRelease(source); | ||
} | ||
} | ||
|
||
private void buildRelease(ReleasesMetadata.ReleaseSource source) throws Exception { | ||
File releasesCache = new File(context.getCacheDir(), "releases/" + source.getId()); | ||
List<Versions.Version> versions = context.versionsFor(source.getId()); | ||
|
||
for (Versions.Version v : context.versions()) { | ||
for (Versions.Version version : versions) { | ||
try { | ||
File releaseCacheDir = new File(releasesCache, v.getVersion()); | ||
File releaseCacheDir = new File(releasesCache, version.getVersion()); | ||
releaseCacheDir.mkdirs(); | ||
|
||
File releaseNotesFile = new File(releaseCacheDir, "release-notes.html"); | ||
File releaseNotesMissingFile = new File(releaseCacheDir, "release-notes.empty"); | ||
|
||
if (releaseNotesFile.isFile()) { | ||
printStep("exists", v.getVersion()); | ||
printStep("exists", source.getId() + " " + version.getVersion()); | ||
} else if (releaseNotesMissingFile.isFile()) { | ||
printStep("missing", v.getVersion()); | ||
printStep("missing", source.getId() + " " + version.getVersion()); | ||
} else { | ||
Map<String, Object> attributes = new HashMap<>(); | ||
|
||
attributes.put("project_buildType", "latest"); | ||
attributes.put("leveloffset", "2"); | ||
attributes.put("fragment", "yes"); | ||
|
||
Map<String, Object> branchAttributes = context.asciiDoctor().parseAttributes(new URL(String.format(DOCUMENT_ATTRIBUTES_BRANCH_URL, v.getVersionShorter())), attributes); | ||
Map<String, Object> tagAttributes = context.asciiDoctor().parseAttributes(new URL(String.format(DOCUMENT_ATTRIBUTES_TAG_URL, v.getVersion())), attributes); | ||
List<String> attributeSources = source.getAttributeSources(); | ||
|
||
attributes.putAll(branchAttributes); | ||
attributes.putAll(tagAttributes); | ||
if (attributeSources != null) { | ||
for (String attributeSource : source.getAttributeSources()) { | ||
URL templateUrl = buildTemplateUrl(source, version, attributeSource); | ||
Map<String, Object> templateAttributes = context.asciiDoctor().parseAttributes(templateUrl, attributes); | ||
attributes.putAll(templateAttributes); | ||
} | ||
} | ||
|
||
String releaseNotesUrl = String.format(RELEASE_NOTES_URL, v.getVersionShorter(), v.getVersion().replace(".", "_")); | ||
URL url = new URL(releaseNotesUrl); | ||
URL releaseNotesURL = buildTemplateUrl(source, version, source.getReleaseNotes()); | ||
|
||
try { | ||
context.asciiDoctor().writeFile(attributes, url, releaseNotesFile.getParentFile(), releaseNotesFile.getName()); | ||
printStep("created", v.getVersion()); | ||
context.asciiDoctor().writeFile(attributes, releaseNotesURL, releaseNotesFile.getParentFile(), releaseNotesFile.getName()); | ||
printStep("created", source.getId() + " " + version.getVersion()); | ||
} catch (FileNotFoundException e) { | ||
printStep("notfound", v.getVersion()); | ||
printStep("notfound", source.getId() + " " + version.getVersion()); | ||
releaseNotesMissingFile.createNewFile(); | ||
} | ||
} | ||
|
||
if (releaseNotesFile.isFile()) { | ||
v.setReleaseNotes("cache/releases/" + v.getVersion() + "/release-notes.html"); | ||
version.setReleaseNotes("cache/releases/" + source.getId() + "/" + version.getVersion() + "/release-notes.html"); | ||
} | ||
} catch (Exception e) { | ||
printStep("error", v.getVersion() + " (" + e.getClass().getSimpleName() + ")"); | ||
printStep("error", source.getId() + " " + version.getVersion() + " (" + e.getClass().getSimpleName() + ")"); | ||
} | ||
} | ||
} | ||
|
||
private URL buildTemplateUrl(ReleasesMetadata.ReleaseSource source, Versions.Version version, String pathTemplate) throws Exception { | ||
Configuration configuration = new Configuration(Configuration.VERSION_2_3_31); | ||
Template template = new Template("template", pathTemplate, configuration); | ||
StringWriter writer = new StringWriter(); | ||
Map<String, Object> attributes = new HashMap<>(); | ||
|
||
attributes.put("version", version); | ||
template.process(attributes, writer); | ||
|
||
String path = writer.toString(); | ||
|
||
return new URL(String.format("https://raw.githubusercontent.com/%s/%s", source.getRepo(), path)); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"date": "2024-10-22", | ||
"version": "26.0.1", | ||
"blogTemplate": 3, | ||
"documentationTemplate": 12, | ||
"downloadTemplate": 24 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"date": "2024-10-31", | ||
"version": "26.0.2", | ||
"blogTemplate": 3, | ||
"documentationTemplate": 12, | ||
"downloadTemplate": 24 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"date": "2024-11-19", | ||
"version": "26.0.3", | ||
"blogTemplate": 3, | ||
"documentationTemplate": 12, | ||
"downloadTemplate": 24 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"date": "2024-10-04", | ||
"version": "26.0.0", | ||
"blogTemplate": 3, | ||
"documentationTemplate": 12, | ||
"downloadTemplate": 24 | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.