Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/release-all-tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Combined release tools

on:
pull_request:
paths:
- 'releaseAll.sh'
- 'scripts/release-all/**'
- 'matrix-bom/verifyBomApi.sh'
- '.github/workflows/release-all-tools.yml'
workflow_dispatch:

permissions:
contents: read

jobs:
portable-tools:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 40
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
- name: Install shell tools
shell: bash
run: |
if [[ "$RUNNER_OS" == macOS ]]; then
brew install bash shellcheck
else
sudo apt-get update
sudo apt-get install -y shellcheck
fi
- name: Prepare Groovy CLI
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/release-cli/bin"
cat > "$RUNNER_TEMP/release-cli/pom.xml" <<'XML'
<project xmlns="http://maven.apache.org/POM/4.0.0"><modelVersion>4.0.0</modelVersion>
<groupId>release.tools</groupId><artifactId>cli</artifactId><version>1</version>
<dependencies>
<dependency><groupId>org.apache.groovy</groupId><artifactId>groovy</artifactId><version>5.1.1</version></dependency>
<dependency><groupId>org.apache.groovy</groupId><artifactId>groovy-json</artifactId><version>5.1.1</version></dependency>
<dependency><groupId>org.apache.groovy</groupId><artifactId>groovy-xml</artifactId><version>5.1.1</version></dependency>
</dependencies></project>
XML
mvn -B -f "$RUNNER_TEMP/release-cli/pom.xml" org.apache.maven.plugins:maven-dependency-plugin:3.11.0:copy-dependencies -DoutputDirectory="$RUNNER_TEMP/release-cli/lib"
cat > "$RUNNER_TEMP/release-cli/bin/groovy" <<'SH'
#!/usr/bin/env bash
exec java -cp "$RUNNER_TEMP/release-cli/lib/*" groovy.ui.GroovyMain "$@"
SH
chmod +x "$RUNNER_TEMP/release-cli/bin/groovy"
echo "$RUNNER_TEMP/release-cli/bin" >> "$GITHUB_PATH"
- name: Verify portable helpers and workflow
shell: bash
run: |
bash -n releaseAll.sh matrix-bom/verifyBomApi.sh scripts/release-all/preflight.sh
shellcheck releaseAll.sh matrix-bom/verifyBomApi.sh scripts/release-all/preflight.sh
groovy scripts/release-all/test-tools.groovy .
groovy scripts/release-all/test-inventory-inheritance.groovy .
groovy scripts/release-all/test-workflow.groovy .
- name: Verify BOM workflows on Linux
if: runner.os == 'Linux'
shell: bash
env:
RUN_EXTERNAL_TESTS: 'false'
RUN_SLOW_TESTS: 'false'
GRADLE_OPTS: '-Dorg.gradle.workers.max=2'
run: |
BOM_VERIFY_REPO="$GITHUB_WORKSPACE/build/releaseAll/bom-verify" bash matrix-bom/verifyBomApi.sh
groovy scripts/release-all/test-manifest-verifier.groovy . build/releaseAll/bom-verify
74 changes: 51 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ plugins {
alias(libs.plugins.benManesVersions) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.alipsaMavenModule)
alias(libs.plugins.alipsaNexusRelease) apply false
}

if (providers.gradleProperty('releaseAllMode').isPresent()) {
apply plugin: 'se.alipsa.nexus-release-plugin'
nexusReleasePlugin.combinedRelease { }
}

description = "Groovy libraries for working with matrix ([][] data)"
Expand Down Expand Up @@ -392,39 +398,61 @@ tasks.register('dependencyUpdates') {
finalizedBy tasks.named('dependencyUpdatesSummary')
}

tasks.register('latestMavenVersions') {
description = 'Lists the latest Maven Central version for each published module'
group = 'Help'
// Resolve all data at configuration time to satisfy configuration cache
def modules = []
subprojects.findAll { it.plugins.hasPlugin('maven-publish') }.each {
modules << [name: it.name, group: it.group.toString(), artifact: it.name]
}
def bomFile = file('matrix-bom/bom.xml')
if (bomFile.exists()) {
def bom = new groovy.xml.XmlSlurper().parse(bomFile)
modules << [name: 'matrix-bom', group: bom.groupId.text(), artifact: bom.artifactId.text()]
// Each published subproject gets its own latestMavenVersions task from nexus-release-plugin.
// This task only covers the Maven-built matrix-bom and matrix-all, which Gradle does not model.
def latestMavenBomVersions = tasks.register('latestMavenBomVersions') {
description = 'Lists the latest Maven Central versions of matrix-bom and matrix-all'
group = 'help'
// Resolve coordinates at configuration time to satisfy the configuration cache.
List<Map<String, String>> modules = ['matrix-bom/bom.xml', 'matrix-bom/pom.xml'].collect { String path ->
def pom = new groovy.xml.XmlSlurper().parse(file(path))
[group: pom.groupId.text(), artifact: pom.artifactId.text()]
}
modules.sort { it.name }

doLast {
def repoBase = 'https://repo1.maven.org/maven2'
modules.each { mod ->
modules.each { Map<String, String> mod ->
try {
def groupPath = mod.group.replace('.', '/')
def metadataUrl = URI.create("${repoBase}/${groupPath}/${mod.artifact}/maven-metadata.xml").toURL()
def metadata = new groovy.xml.XmlSlurper().parseText(metadataUrl.text)
def metadataUrl = URI.create("https://repo1.maven.org/maven2/${mod.group.replace('.', '/')}/${mod.artifact}/maven-metadata.xml").toURL()
def connection = metadataUrl.openConnection()
connection.connectTimeout = 5000
connection.readTimeout = 5000
def metadata = connection.inputStream.withCloseable { new groovy.xml.XmlSlurper().parse(it) }
def latest = metadata.versioning.release.text() ?: metadata.versioning.latest.text()
if (latest) {
println "${mod.name}: ${mod.group}:${mod.artifact}:${latest}"
println "${mod.artifact}: ${mod.group}:${mod.artifact}:${latest}"
} else {
println "${mod.name}: no release version found"
println "${mod.artifact}: no release version found"
}
} catch (FileNotFoundException e) {
println "${mod.name}: not found on Maven Central"
} catch (FileNotFoundException ignored) {
println "${mod.artifact}: not found on Maven Central"
} catch (Exception e) {
println "${mod.name}: error querying Maven Central (${e.message})"
println "${mod.artifact}: error querying Maven Central (${e.message})"
}
}
}
}

if (providers.gradleProperty('releaseAllMode').isPresent()) {
// The plugin's root task would list every subproject again; keep only the Maven-built modules.
tasks.named('latestMavenVersions') {
enabled = false
dependsOn latestMavenBomVersions
}
} else {
tasks.register('latestMavenVersions') {
description = 'Lists the latest Maven Central version of matrix-bom and matrix-all; subprojects list their own'
group = 'help'
dependsOn latestMavenBomVersions
}
}

if (providers.gradleProperty('releaseAllMode').isPresent()) {
subprojects {
tasks.withType(Test).configureEach {
useJUnitPlatform { excludeTags 'flaky' }
}
}
gradle.projectsEvaluated {
apply from: 'gradle/release-all.gradle'
}
}
Loading
Loading