Skip to content

Commit

Permalink
Generate release notes (#55)
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel-Trintinalia <[email protected]>
  • Loading branch information
Gabriel-Trintinalia authored Aug 22, 2024
1 parent 1c65de8 commit f153739
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
13 changes: 1 addition & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,11 @@ jobs:
env:
JAVA_OPTS: -Xmx2g -Dorg.gradle.daemon=false

- name: Generate Release body
id: generate_body
continue-on-error: true
run: |
config=$(cat linea-besu/build.json)
echo "## Release Notes" > output.md
echo "" >> output.md
echo "| Module | Version |" >> output.md
echo "|--------|---------|" >> output.md
echo "$config" | jq -r '.modules[] | select(.src == null) | "| **\(.name)** | \(.version // "[source](\(.url))") |"' >> output.md
- name: Draft Release
uses: softprops/action-gh-release@v2
with:
body_path: output.md
name: Release ${{ github.ref_name }}
body_path: build/release-notes.md
generate_release_notes: true
fail_on_unmatched_files: true
draft: true
Expand Down
37 changes: 37 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,43 @@ tasks.register('cleanDist') {
delete "$DISTRIBUTIONS_DIR"
}

// Task to generate release-notes.md
tasks.register('generateReleaseNotes') {
dependsOn distTar
doLast {
def releaseNotesFile = file("$buildDir/release-notes.md")
if (releaseNotesFile.exists()) {
releaseNotesFile.delete()
}
releaseNotesFile.text = "## Release Notes\n\n| Module | Version | SHA-256 |\n|--------|---------|---------|\n"
modules.each { module ->
if (module.src == null) {
def versionInfo = module.version ? module.version : "[source](${module.url})"
def fileName = getFileNameFromUrl(module.url.replace("{version}", module.version))
def filePath = "$DOWNLOADS_DIR/$fileName"
def sha256Hex = file(filePath).exists() ? DigestUtils.sha256Hex(new FileInputStream(filePath)) : "N/A"
releaseNotesFile.append("| **${module.name}** | ${versionInfo} | ${sha256Hex} |\n")
}
}

// Add title and SHA-256 digest of the distTar artifact
def tarFile = file("$DISTRIBUTIONS_DIR/${config.distIdentifier}-${version}.tar.gz")
if (tarFile.exists()) {
def sha256Hex = DigestUtils.sha256Hex(new FileInputStream(tarFile))
releaseNotesFile.append("\n### Release Artifact\n")
releaseNotesFile.append("${tarFile.name}\n")
releaseNotesFile.append("SHA-256: ${sha256Hex}\n")
} else {
throw new GradleException("Tar file not found: $tarFile")
}
}
}

// Ensure release notes are generated during the build
tasks.build {
dependsOn 'generateReleaseNotes'
}

processModules.dependsOn(cleanDist)

// Apply additional Gradle script for Docker
Expand Down

0 comments on commit f153739

Please sign in to comment.