Docker release builds to no longer add latest tag (#4791)

Signed-off-by: Jason Frame <jason.frame@consensys.net>
Co-authored-by: Justin Florentine <justin+github@florentine.us>
pull/4799/head
Jason Frame 2 years ago committed by GitHub
parent 19077be0a1
commit 1205e3a6f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      .github/workflows/release.yml
  2. 29
      build.gradle
  3. 9
      ethereum/evmtool/build.gradle

@ -0,0 +1,16 @@
name: release besu
on:
release:
types: released
jobs:
dockerPromoteX64:
runs-on: ubuntu-latest
steps:
- name: Login to DockerHub
run: echo ${{ secrets.DOCKER_PASSWORD_RW }} | docker login -u ${{ secrets.DOCKER_USER_RW }} --password-stdin
- name: pull tagged image
run: docker pull ${{ secrets.DOCKER_ORG }}/besu:gitSha-${{ github.sha }}
- name: apply latest tag
run: docker tag ${{ secrets.DOCKER_ORG }}/besu:gitSha-${{ github.sha }} ${{ secrets.DOCKER_ORG }}/besu:latest
- name: push
run: docker push ${{ secrets.DOCKER_ORG }}/besu:latest

@ -605,7 +605,9 @@ artifactoryPublish {
} }
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def dockerImageName = project.hasProperty("dockerImageName") ? project.getProperty("dockerImageName") : "hyperledger/besu" def dockerOrgName = project.hasProperty('dockerOrgName') ? project.getProperty("dockerOrgName") : "hyperledger"
def dockerArtifactName = project.hasProperty("dockerArtifactName") ? project.getProperty("dockerArtifactName") : "besu"
def dockerImageName = "${dockerOrgName}/${dockerArtifactName}"
def dockerVariants = project.hasProperty("dockerVariants") ? project.getProperty("dockerVariants").split(",") : [ def dockerVariants = project.hasProperty("dockerVariants") ? project.getProperty("dockerVariants").split(",") : [
"openjdk-11", "openjdk-11",
"openjdk-11-debug", "openjdk-11-debug",
@ -639,18 +641,25 @@ task distDocker {
def dockerBuildDir = "build/docker-besu/" def dockerBuildDir = "build/docker-besu/"
doLast { doLast {
for (def variant in dockerVariants) { for (def jvmVariant in dockerVariants) {
copy { copy {
from file("${projectDir}/docker/${variant}/Dockerfile") from file("${projectDir}/docker/${jvmVariant}/Dockerfile")
into(dockerBuildDir) into(dockerBuildDir)
} }
exec { exec {
def image = "${dockerImageName}:${dockerBuildVersion}-${variant}" def image = "${dockerImageName}:${dockerBuildVersion}-${jvmVariant}"
executable "sh" executable "sh"
workingDir dockerBuildDir workingDir dockerBuildDir
args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ." args "-c", "docker build --build-arg BUILD_DATE=${buildTime()} --build-arg VERSION=${dockerBuildVersion} --build-arg VCS_REF=${getCheckedOutGitCommitHash()} -t ${image} ."
} }
} }
def shaTag = "gitSha-${getCheckedOutGitCommitHash(40)}" //full length sha
exec {
executable "sh"
args "-c", "docker tag '${dockerImageName}:${dockerBuildVersion}-${dockerVariants[0]}' '${dockerImageName}:${shaTag}'"
}
// tag the "default" (which is the variant in the zero position) // tag the "default" (which is the variant in the zero position)
exec { exec {
executable "sh" executable "sh"
@ -730,10 +739,9 @@ task dockerUpload {
} }
def isInterimBuild = (dockerBuildVersion ==~ /.*-SNAPSHOT/) || (dockerBuildVersion ==~ /.*-alpha/) def isInterimBuild = (dockerBuildVersion ==~ /.*-SNAPSHOT/) || (dockerBuildVersion ==~ /.*-alpha/)
|| (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC/) || (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC.*/)
if (!isInterimBuild) { if (!isInterimBuild) {
additionalTags.add('latest')
additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.')) additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.'))
} }
@ -760,6 +768,7 @@ task dockerUpload {
} }
task manifestDocker { task manifestDocker {
dependsOn distDocker
def image = "${dockerImageName}:${dockerBuildVersion}" def image = "${dockerImageName}:${dockerBuildVersion}"
def archs = ["arm64", "amd64"] def archs = ["arm64", "amd64"]
@ -770,7 +779,6 @@ task manifestDocker {
} }
if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) { if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) {
tags.add("${dockerImageName}:latest")
tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.')) tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.'))
} }
@ -865,15 +873,16 @@ def calculateVersion() {
return version return version
} }
def getCheckedOutGitCommitHash() {
def getCheckedOutGitCommitHash(length = 8) {
try { try {
def gitFolder = "$projectDir/.git/" def gitFolder = "$projectDir/.git/"
if (!file(gitFolder).isDirectory()) { if (!file(gitFolder).isDirectory()) {
// We are in a submodule. The file's contents are `gitdir: <gitFolder>\n`. // We are in a submodule. The file's contents are `gitdir: <gitFolder>\n`.
// Read the file, cut off the front, and trim the whitespace. // Read the file, cut off the front, and trim the whitespace.
gitFolder = file(gitFolder).text.substring(8).trim() + "/" gitFolder = file(gitFolder).text.substring(length).trim() + "/"
} }
def takeFromHash = 8 def takeFromHash = length
/* /*
* '.git/HEAD' contains either * '.git/HEAD' contains either
* in case of detached head: the currently checked out commit hash * in case of detached head: the currently checked out commit hash

@ -103,7 +103,10 @@ tasks.register("dockerDistUntar") {
task distDocker(type: Exec) { task distDocker(type: Exec) {
dependsOn dockerDistUntar dependsOn dockerDistUntar
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu-evmtool" def dockerOrgName = project.hasProperty('dockerOrgName') ? project.getProperty("dockerOrgName") : "hyperledger"
def dockerArtifactName = project.hasProperty("dockerArtifactName") ? project.getProperty("dockerArtifactName") : "besu-evmtool"
def imageName = "${dockerOrgName}/${dockerArtifactName}"
def image = "${imageName}:${dockerBuildVersion}" def image = "${imageName}:${dockerBuildVersion}"
def dockerBuildDir = "${buildDir}/docker-besu-evmtool/" def dockerBuildDir = "${buildDir}/docker-besu-evmtool/"
workingDir "${dockerBuildDir}" workingDir "${dockerBuildDir}"
@ -122,7 +125,9 @@ task distDocker(type: Exec) {
task dockerUpload(type: Exec) { task dockerUpload(type: Exec) {
dependsOn distDocker dependsOn distDocker
def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}" def dockerBuildVersion = project.hasProperty('release.releaseVersion') ? project.property('release.releaseVersion') : "${rootProject.version}"
def imageName = "hyperledger/besu-evmtool" def dockerOrgName = project.hasProperty('dockerOrgName') ? project.getProperty("dockerOrgName") : "hyperledger"
def dockerArtifactName = project.hasProperty("dockerArtifactName") ? project.getProperty("dockerArtifactName") : "besu-evmtool"
def imageName = "${dockerOrgName}/${dockerArtifactName}"
def image = "${imageName}:${dockerBuildVersion}" def image = "${imageName}:${dockerBuildVersion}"
def cmd = "docker push '${image}'" def cmd = "docker push '${image}'"
def additionalTags = [] def additionalTags = []

Loading…
Cancel
Save