Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Make release build cope with v prefixed tags
Browse files Browse the repository at this point in the history
As we want to publish our images without the `v` prefix, some
modifications have been made to the `docker/image-tag` helper script to
remove the `v` prefix from the calculated tag.

In addition, the amount of tags it returns has been limited to one, as
multiple tags will make the build fail due to

`-ldflags "-X main.version=<tagA> <tagB>"`

not being a valid argument.
  • Loading branch information
hiddeco committed Oct 3, 2019
1 parent e4dc79e commit 187e101
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
18 changes: 15 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,23 @@ jobs:
- deploy:
name: Maybe push release image
command: |
if echo "${CIRCLE_TAG}" | grep -Eq "^[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?$"; then
if echo "${CIRCLE_TAG}" | grep -Eq "^v[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?$"; then
echo "$DOCKER_FLUXCD_PASSWORD" | docker login --username "$DOCKER_FLUXCD_USER" --password-stdin
docker push "docker.io/fluxcd/helm-operator:${CIRCLE_TAG}"
docker push "docker.io/fluxcd/helm-operator:$(docker/image-tag)"
fi
# Republish tag _without_ the `v` prefix, for historical reasons
git config --global user.email fluxcdbot@users.noreply.github.com
git config --global user.name fluxcdbot
REPOSITORY="https://fluxcdbot:${GITHUB_TOKEN}@github.com/fluxcd/flux.git"
git remote set-url origin ${REPOSITORY}
# Remove `v` prefix using bash string manipulation
VLESS_TAG=${CIRCLE_TAG#v}
git tag ${VLESS_TAG} $(git rev-list -n1 ${CIRCLE_TAG})
git push origin ${VLESS_TAG}
helm:
docker:
- image: circleci/golang:1.12
Expand Down Expand Up @@ -133,7 +145,7 @@ workflows:
- build:
filters:
tags:
only: /[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?/
only: /v[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?/
release-helm:
jobs:
- helm:
Expand Down
12 changes: 6 additions & 6 deletions docker/image-tag
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ if [ "${1:-}" = '--show-diff' ]; then
fi

# If a tagged version, just print that tag
HEAD_TAGS=$(git tag --points-at HEAD)
if [ -n "${HEAD_TAGS}" ] ; then
# remove helm- prefix from helm-op release name
if echo "${HEAD_TAGS}" | grep -Eq "helm-[0-9]+(\.[0-9]+)*(-[a-z]+)?$"; then
HEAD_TAGS=$(echo "$HEAD_TAGS" | cut -c 6-)
HEAD_TAG=$(git tag --points-at HEAD | head -n1)
if [ -n "${HEAD_TAG}" ] ; then
# remove `v` prefix from release name
if echo "${HEAD_TAG}" | grep -Eq "^v[0-9]+(\.[0-9]+)*(-[a-z0-9]+)?$"; then
HEAD_TAG=$(echo "$HEAD_TAG" | cut -c 2-)
fi
echo ${HEAD_TAGS}
echo ${HEAD_TAG}
exit 0
fi

Expand Down

0 comments on commit 187e101

Please sign in to comment.