Skip to content

Commit

Permalink
Publish to public temp tags instead of private
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Feb 19, 2024
1 parent c9cc345 commit fbd6fd3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."
. bin/stack-helpers.sh

REPO="heroku/heroku"
STACK_VERSION=${1:-"NAN"}
REPO=${2:-"heroku/heroku"}
PUBLISH_SUFFIX=${3:-}
PUBLISH_SUFFIX=${2:-}
BASE_NAME=$(basename "${BASH_SOURCE[0]}")

print_usage(){
Expand Down
30 changes: 14 additions & 16 deletions bin/publish-to-registries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,35 @@ set -x
echo "${DOCKER_HUB_TOKEN}" | docker login -u "${DOCKER_HUB_USERNAME}" --password-stdin
)

date=$(date -u '+%Y-%m-%d-%H.%M.%S')
datedTagSuffix=".${date}"
publicRepo="heroku/heroku"
privateRepo="heroku/heroku-private"
publicTag="${publicRepo}:${STACK_VERSION}"

# build+push dated tags to private dockerhub (e.g. heroku/heroku-private:22.2022-06-01-17.00.00)
bin/build.sh "${STACK_VERSION}" "${privateRepo}" "${datedTagSuffix}"

push_group() {
local targetTagBase="$1"
local targetTagSuffix="$2"
local tagBase="$1"
local sourceTagSuffix="$2"
local targetTagSuffix="$3"
variants=("" "-build")
if (( STACK_VERSION <= 22 )); then
variants+=("-cnb" "-cnb-build")
fi
for variant in "${variants[@]}"; do
source="${privateRepo}:${STACK_VERSION}${variant}${datedTagSuffix}"
target="${targetTagBase}${variant}${targetTagSuffix}"
source="${tagBase}${variant}${sourceTagSuffix}"
target="${tagBase}${variant}${targetTagSuffix}"
docker tag "${source}" "${target}"
docker push "${target}"
done
}

tempTagSuffix=".temp_${GITHUB_RUN_ID}"
# build+push to a temporary tag (e.g. heroku/heroku:22.temp_12345678)
bin/build.sh "${STACK_VERSION}" "${tempTagSuffix}"

publicTag="heroku/heroku:${STACK_VERSION}"

# Push nightly tags to Docker Hub (e.g. heroku/heroku:22.nightly)
push_group "${publicTag}" ".nightly"
push_group "${publicTag}" "${tempTagSuffix}" ".nightly"

if [[ "$GITHUB_REF_TYPE" == 'tag' ]]; then
# Push release tags to Docker Hub (e.g. heroku/heroku:22.v99)
push_group "${publicTag}" ".${GITHUB_REF_NAME}"
push_group "${publicTag}" "${tempTagSuffix}" ".${GITHUB_REF_NAME}"

# Push latest/no-suffix tags to Docker Hub (e.g. heroku/heroku:22)
push_group "${publicTag}" ""
push_group "${publicTag}" "${tempTagSuffix}" ""
fi

0 comments on commit fbd6fd3

Please sign in to comment.