Simplify image tagging script
Simplify image tagging script

In #1047, there's some debate about the logic here. Maybe it can
simplified.

We first tag the image with the git-based tag.

We always add one additional tag - if we're on master, we use
'latest'. Otherwise, we have been supplied a semver tag in
BASE_REF, and we can use that.

The only difference in the logic vs #1047 should be that we don't set
COMMIT in the go binary to the semver tag, which seems wrong anyway?

Before this change:

  $ podman run -it --restart no --rm gcr.io/k8s-staging-gateway-api/admission-server:v20220324-v0.4.0-177-g6d6fe85 -version
  gateway-api-admission-webhook version: v20220324-v0.4.0-177-g6d6fe85 (6d6fe856860b2cf243ad5574b7346138636f80d6)
  $ podman run -it --restart no --rm gcr.io/k8s-staging-gateway-api/admission-server:v0.4.2-test -version
  gateway-api-admission-webhook version: v0.4.2-test (v0.4.2-test)

and after:

  $ podman run -it --restart no --rm quay.io/markmc/admission-server:latest -version
  gateway-api-admission-webhook version: v0.4.0-177-g6d6fe85 (6d6fe856860b2cf243ad5574b7346138636f80d6)
  $ podman run -it --restart no --rm quay.io/markmc/admission-server:v0.4.2-test1 -version
  gateway-api-admission-webhook version: v0.4.2-test1 (6d6fe856860b2cf243ad5574b7346138636f80d6)

Tested:

  GIT_TAG=$(git describe --tags origin/master) COMMIT=$(git rev-parse origin/master) REGISTRY=quay.io/markmc ./hack/build-and-push.sh

with BASE_REF=master and BASE_REF=v0.4.2-test1.

istio/gateway-api,istio/gateway-api,istio/gateway-api