diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 06ce752..66926b9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/build.gradle b/build.gradle index 6fa35dd..52cdaa6 100644 --- a/build.gradle +++ b/build.gradle @@ -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