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 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(",") : [
"openjdk-11",
"openjdk-11-debug",
@ -639,18 +641,25 @@ task distDocker {
def dockerBuildDir = "build/docker-besu/"
doLast {
for (def variant in dockerVariants) {
for (def jvmVariant in dockerVariants) {
copy {
from file("${projectDir}/docker/${variant}/Dockerfile")
from file("${projectDir}/docker/${jvmVariant}/Dockerfile")
into(dockerBuildDir)
}
exec {
def image = "${dockerImageName}:${dockerBuildVersion}-${variant}"
def image = "${dockerImageName}:${dockerBuildVersion}-${jvmVariant}"
executable "sh"
workingDir dockerBuildDir
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)
exec {
executable "sh"
@ -730,10 +739,9 @@ task dockerUpload {
}
def isInterimBuild = (dockerBuildVersion ==~ /.*-SNAPSHOT/) || (dockerBuildVersion ==~ /.*-alpha/)
|| (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC/)
|| (dockerBuildVersion ==~ /.*-beta/) || (dockerBuildVersion ==~ /.*-RC.*/)
if (!isInterimBuild) {
additionalTags.add('latest')
additionalTags.add(dockerBuildVersion.split(/\./)[0..1].join('.'))
}
@ -760,6 +768,7 @@ task dockerUpload {
}
task manifestDocker {
dependsOn distDocker
def image = "${dockerImageName}:${dockerBuildVersion}"
def archs = ["arm64", "amd64"]
@ -770,7 +779,6 @@ task manifestDocker {
}
if (!(dockerBuildVersion ==~ /.*-SNAPSHOT/)) {
tags.add("${dockerImageName}:latest")
tags.add("${dockerImageName}:" + dockerBuildVersion.split(/\./)[0..1].join('.'))
}
@ -865,15 +873,16 @@ def calculateVersion() {
return version
}
def getCheckedOutGitCommitHash() {
def getCheckedOutGitCommitHash(length = 8) {
try {
def gitFolder = "$projectDir/.git/"
if (!file(gitFolder).isDirectory()) {
// We are in a submodule. The file's contents are `gitdir: <gitFolder>\n`.
// 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
* in case of detached head: the currently checked out commit hash

@ -103,7 +103,10 @@ tasks.register("dockerDistUntar") {
task distDocker(type: Exec) {
dependsOn dockerDistUntar
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 dockerBuildDir = "${buildDir}/docker-besu-evmtool/"
workingDir "${dockerBuildDir}"
@ -122,7 +125,9 @@ task distDocker(type: Exec) {
task dockerUpload(type: Exec) {
dependsOn distDocker
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 cmd = "docker push '${image}'"
def additionalTags = []

Loading…
Cancel
Save