Skip to content

Commit

Permalink
Make build reproducible (#63)
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 23, 2024
1 parent 51dd674 commit cdbc6be
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
31 changes: 30 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,36 @@ tasks.register('prepareDistFolder', Copy) {
into newFolderPath
}

tasks.register('updateModifiedDates') {
dependsOn 'prepareDistFolder'

def newFolderName = "${config.distIdentifier}-${version}"
def newFolderPath = "$TAR_DIR/$newFolderName"

doLast {
// Get the last commit timestamp
def lastCommitTimestamp = 'git log -1 --format=%ct'.execute().text.trim()
def lastCommitTimeInMillis = Long.parseLong(lastCommitTimestamp) * 1000

println "Last commit timestamp (in milliseconds): ${lastCommitTimeInMillis}"

// Update the modified date of all files and folders in the specified folder
def folder = file(newFolderPath)
if (folder.exists() && folder.isDirectory()) {
folder.eachFileRecurse { file ->
file.setLastModified(lastCommitTimeInMillis)
}
// Update the modified date of the folder itself
folder.setLastModified(lastCommitTimeInMillis)
} else {
println "Folder does not exist or is not a directory: ${newFolderPath}"
}
}
}

// Register a task to create a tar archive of the distribution
tasks.register('distTar', Tar) {
dependsOn prepareDistFolder
dependsOn 'prepareDistFolder', 'updateModifiedDates'

def outputTarGzFileName = "${config.distIdentifier}-${version}.tar.gz"

Expand Down Expand Up @@ -304,6 +331,8 @@ tasks.register('generateReleaseNotes') {
}
}



// Ensure release notes are generated during the build
tasks.build {
dependsOn 'generateReleaseNotes'
Expand Down
5 changes: 2 additions & 3 deletions gradle/docker.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ def shell = org.gradle.internal.os.OperatingSystem.current().isWindows() ? "${pr
// http://label-schema.org/rc1/
// using the RFC3339 format "2016-04-12T23:20:50.52Z"
def buildTime() {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
def gitDate = 'git log -1 --format=%cI'.execute().text.trim()
return gitDate
}

// rename the top level dir from besu-<version> to besu and this makes it really
Expand Down

0 comments on commit cdbc6be

Please sign in to comment.