Commit d4a8883b authored by Florian Schäfer's avatar Florian Schäfer

Add Gradle task that creates a JOSM plugin update site

This update site offers the latest available plugin version for both the `wikipedia` plugin and for the `pt_assistant` plugin.
The site will be published at https://josm.github.io/wikipedia/pluginMasterSnapshots
parent 20cae900
......@@ -48,7 +48,7 @@ jobs:
fi
- checkout
# Main commands
- run: ./gradlew assemble test generatePot
- run: ./gradlew assemble test generatePot generateMasterPluginList
# Storing to cache/workspace
- persist_to_workspace: &persist_build_artifacts
root: .
......@@ -56,6 +56,21 @@ jobs:
- .tx
- build
- save_cache: *save_gradleGit_cache
- store_artifacts:
path: ./build/dist
destination: dist
- store_artifacts:
path: ./build/tmp/jar/MANIFEST.MF
destination: dist/MANIFEST.MF
- run: |
git fetch origin gh-pages
git checkout gh-pages
cp ./build/pluginMasterSnapshots .
git stage pluginMasterSnapshots
git config user.name "CircleCI $CIRCLE_BUILD_NUM"
git config user.email "deploy@circleci"
git commit -m "[ci skip] Update plugin update site for JOSM with latest version from master branch"
git push -q https://${GITHUB_TOKEN}@github.com/JOSM/wikipedia.git gh-pages > /dev/null 2>&1
min-josm:
docker: *jdk8_image
......@@ -98,12 +113,6 @@ jobs:
# Store artifacts
- store_test_results:
path: ./build/test-results/test
- store_artifacts:
path: ./build/dist
destination: dist
- store_artifacts:
path: ./build/tmp/jar/MANIFEST.MF
destination: dist/MANIFEST.MF
- store_artifacts:
path: ./build/reports/jacoco/test
destination: jacoco
......
import java.nio.file.Files
import java.nio.file.Paths
import java.time.Duration
import java.time.Instant
import java.util.jar.JarInputStream
import java.util.regex.Pattern
import java.util.stream.Collectors
import org.openstreetmap.josm.gradle.plugin.task.GeneratePluginList
plugins {
id "java"
......@@ -10,7 +15,7 @@ plugins {
id "com.github.ben-manes.versions" version "0.17.0"
id "com.github.spotbugs" version "1.6.1"
id "net.ltgt.errorprone" version "0.0.14"
id "org.openstreetmap.josm" version "0.4.2"
id "org.openstreetmap.josm" version "0.4.4"
}
def versions = [
errorprone: "2.3.1",
......@@ -130,6 +135,43 @@ tasks.withType(com.github.spotbugs.SpotBugsTask) {
}
}
task generateMasterPluginList(type: GeneratePluginList) {
dependsOn(tasks.processResources)
outputFile = file("$buildDir/pluginMasterSnapshots")
def defaultVersionSuffix = versionSuffix
versionSuffix = {String s ->
if (s.startsWith(archivesBaseName)) {
return ""
}
return defaultVersionSuffix.invoke(s)
}
doFirst {
def wikipediaURL = System.getenv("WIKIPEDIA_URL")
def ptAssistantURL = System.getenv("PT_ASSISTANT_URL")
if (wikipediaURL == null || ptAssistantURL == null) {
throw new TaskExecutionException(it, new IllegalStateException("This tasks requires the environment variables `WIKIPEDIA_URL` and `PT_ASSISTANT_URL` to be set!"))
}
def circleBuildNum = System.getenv("CIRCLE_BUILD_NUM")
if (wikipediaURL.count("%s") == 1 && circleBuildNum != null) {
wikipediaURL = String.format(wikipediaURL, circleBuildNum)
}
it.iconBase64Provider = {
def file = new File(sourceSets.main.resources.srcDirs[0], it)
if (file.exists()) {
def contentType = file.name.endsWith(".svg") ? "svg+xml" : "png"
return "data:image/" + contentType + ";base64," + Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(file.toURI())));
}
}
it.addPlugin("$archivesBaseName-dev.jar", project.josm.manifest.createJosmPluginJarManifest(), new URL(wikipediaURL))
def manifestAttributes = new JarInputStream(new URL(ptAssistantURL).openConnection().inputStream).manifest.mainAttributes.entrySet().stream()
.collect(Collectors.toMap({ e -> e.key.toString()}, { e -> e.value.toString()}))
it.addPlugin("pt_assistant-dev.jar", manifestAttributes, new URL(ptAssistantURL))
}
}
/**
* @return the current version of the repo as determined by the first of these commands that returns a valid result:
* <ul>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment