Skip to content

Commit

Permalink
Edit ambassador.version when promoting an image
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Shumaker <[email protected]>
  • Loading branch information
LukeShu committed Sep 17, 2021
1 parent 02c5ddd commit 0f6534e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ indent_style = tab
[{*.sh,cluster-claim,cluster-unclaim}]
indent_style = space
indent_size = 4
[docker-promote.sh]
indent_style = tab
indent_size = 8
tab_width = 8

[*.el]
indent_style = space
Expand Down
1 change: 1 addition & 0 deletions build-aux/tools.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ clobber-tools:
# =============
#
tools/copy-ifchanged = $(tools.bindir)/copy-ifchanged
tools/docker-promote = $(tools.bindir)/docker-promote
tools/move-ifchanged = $(tools.bindir)/move-ifchanged
tools/tap-driver = $(tools.bindir)/tap-driver
tools/write-dockertagfile = $(tools.bindir)/write-dockertagfile
Expand Down
5 changes: 2 additions & 3 deletions builder/builder.mk
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ RELEASE_VERSION=$$($(BUILDER) release-version)
BUILD_VERSION=$$($(BUILDER) version)
IS_DIRTY=$$($(BUILDER) is-dirty)

release/promote-oss/.main:
release/promote-oss/.main: $(tools/docker-promote)
@[[ "$(RELEASE_VERSION)" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$$ ]] || (echo "MUST SET RELEASE_VERSION"; exit 1)
@[[ -n "$(PROMOTE_FROM_VERSION)" ]] || (echo "MUST SET PROMOTE_FROM_VERSION"; exit 1)
@[[ '$(PROMOTE_TO_VERSION)' =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.*)?$$ ]] || (echo "MUST SET PROMOTE_TO_VERSION" ; exit 1)
Expand All @@ -736,8 +736,7 @@ release/promote-oss/.main:
exit 1; \
fi ; \
printf ' $(CYN)$${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION)$(END)\n' ; \
docker pull $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) && \
docker tag $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) && \
$(tools/docker-promote) $${pullregistry}/$(REPO):$(PROMOTE_FROM_VERSION) $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) && \
docker push $(RELEASE_REGISTRY)/$(REPO):$(PROMOTE_TO_VERSION) ;\
}

Expand Down
17 changes: 16 additions & 1 deletion docs/releaseNotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@

changelog: https://github.com/emissary-ingress/emissary/blob/$branch$/CHANGELOG.md
items:
- version: 2.0.4-ea
date: "TBD"
notes:
- title: Developer Preview!
body: We're pleased to introduce $productName$ 2.0.3 as a <b>developer preview</b>. The 2.X family introduces a number of changes to allow $productName$ to more gracefully handle larger installations, reduce global configuration to better handle multitenant or multiorganizational installations, reduce memory footprint, and improve performance. We welcome feedback!! Join us on <a href="https://a8r.io/slack">Slack</a> and let us know what you think.
type: change
isHeadline: true
docs: about/changes-2.0.0

- type: bugfix
title: Version number reported correctly
body: >-
The release now shows its actual released version number, rather than
the internal development version number.
- version: 2.0.3-ea
date: "TBD"
notes:
Expand Down Expand Up @@ -198,7 +213,7 @@ items:

- title: Service Preview no longer supported
body: >-
Service Preview and the <code>AGENT_SERVICE</code> environment variable are no longer supported.
Service Preview and the <code>AGENT_SERVICE</code> environment variable are no longer supported.
The Telepresence product replaces this functionality.
docs: https://www.getambassador.io/docs/telepresence/
type: change
Expand Down
49 changes: 49 additions & 0 deletions tools/src/docker-promote.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

set -euE

usage() {
echo "Usage: ${0##*/} FROM_IMAGE TO_REPO:TO_VERSION"
}

errUsage() {
printf '%s: error: %s' "$*"
usage >&2
exit 2
}

main() {
for arg in "$@"; do
if [[ $arg == '--help' ]]; then
usage
exit 0
fi
done
if [[ $# != 2 ]]; then
errUsage "expected exactly 2 arguments, got $#"
fi
from=$1
to=$2
if [[ $to != *:* ]]; then
errUsage "does not look like a REPO:VERSION pair: ${to}"
fi
toVersion=${to##*:}

toVersion_base=${toVersion%%-*}
toVersion_extra=${toVersion#"$toVersion_base"}
tmpdir=$(mktemp -d -t docker-promote.XXXXXXXXXX)
trap 'rm -rf "$tmpdir"' EXIT
cat >"$tmpdir/Dockerfile" <<-EOF
FROM ${from}
RUN find / -name ambassador.version -exec sed -i \\
-e 's/^BASE_VERSION=.*/BASE_VERSION="${toVersion_base}"/' \\
-e 's/^EXTRA_VERSION=.*/EXTRA_VERSION="${toVersion_extra}"/' \\
-e 's/^RELEASE_VERSION=.*/RELEASE_VERSION="${toVersion}"/' \\
-e 's/^BUILD_VERSION=.*/BUILD_VERSION="${toVersion}"/' \\
-- {} +
EOF

docker build -t "$to" "$tmpdir"
}

main "$@"

0 comments on commit 0f6534e

Please sign in to comment.