Skip to content

Commit 8232cdb

Browse files
committed
Simplify to single build push stage
Signed-off-by: Terence <terencelimxp@gmail.com>
1 parent e662792 commit 8232cdb

1 file changed

Lines changed: 20 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -68,53 +68,37 @@ jobs:
6868
export_default_credentials: true
6969
project_id: ${{ secrets.GCP_PROJECT_ID }}
7070
service_account_key: ${{ secrets.GCP_SA_KEY }}
71+
- run: gcloud auth configure-docker --quiet
7172
- name: Get m2 cache
7273
run: |
7374
infra/scripts/download-maven-cache.sh \
7475
--archive-uri ${MAVEN_CACHE} \
7576
--output-dir .
76-
- name: Build and push latest image to Dockerhub
77-
uses: docker/build-push-action@v2
77+
- name: Build and push versioned images
7878
env:
7979
RELEASE_VERSION: ${{ needs.get-version.outputs.release_version }}
8080
VERSION_WITHOUT_PREFIX: ${{ needs.get-version.outputs.version_without_prefix }}
8181
HIGHEST_SEMVER_TAG: ${{ needs.get-version.outputs.highest_semver_tag }}
82-
with:
83-
if: ${VERSION_WITHOUT_PREFIX} == ${HIGHEST_SEMVER_TAG:1}
84-
push: true
85-
context: .
86-
file: ./infra/docker/${{ matrix.component }}/Dockerfile
87-
tags: |
88-
feastdev/feast-${{ matrix.component }}:${{ needs.get-version.outputs.release_version }}
89-
feastdev/feast-${{ matrix.component }}:latest
90-
build-args: |
91-
VERSION=$RELEASE_VERSION
92-
- name: Build and push versioned image to GCR
93-
env:
94-
RELEASE_VERSION: ${{ needs.get-version.outputs.release_version }}
9582
run: |
96-
make build-${{ matrix.component }}-docker REGISTRY=gcr.io/kf-feast VERSION=$RELEASE_VERSION
97-
make push-${{ matrix.component }}-docker REGISTRY=gcr.io/kf-feast VERSION=$RELEASE_VERSION
98-
source infra/scripts/setup-common-functions.sh
99-
# Build and push semver tagged commits
100-
# Regular expression should match MAJOR.MINOR.PATCH[-PRERELEASE[.IDENTIFIER]]
101-
# eg. v0.7.1 v0.7.2-alpha v0.7.2-rc.1
102-
SEMVER_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$'
103-
if echo "${RELEASE_VERSION}" | grep -P "$SEMVER_REGEX" &>/dev/null ; then
104-
VERSION_WITHOUT_PREFIX=${RELEASE_VERSION:1}
105-
106-
docker tag gcr.io/kf-feast/feast-${{ matrix.component }}:${GITHUB_SHA} gcr.io/kf-feast/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX}
83+
docker build --build-arg VERSION=$RELEASE_VERSION \
84+
-t gcr.io/kf-feast/feast-${{ matrix.component }}:${GITHUB_SHA} \
85+
-t gcr.io/kf-feast/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX} \
86+
-f infra/docker/${{ matrix.component }}/Dockerfile .
87+
docker push gcr.io/kf-feast/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX}
88+
89+
echo "Only push to latest tag if tag is the highest semver version $HIGHEST_SEMVER_TAG"
90+
if [ "${VERSION_WITHOUT_PREFIX}" = "${HIGHEST_SEMVER_TAG:1}" ]
91+
then
92+
docker build --build-arg VERSION=$RELEASE_VERSION \
93+
-t feastdev/feast-${{ matrix.component }}:latest \
94+
-t feastdev/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX} \
95+
-t gcr.io/kf-feast/feast-${{ matrix.component }}:latest \
96+
-t gcr.io/kf-feast/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX} \
97+
-f infra/docker/${{ matrix.component }}/Dockerfile .
98+
docker push feastdev/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX}
99+
docker push feastdev/feast-${{ matrix.component }}:latest
107100
docker push gcr.io/kf-feast/feast-${{ matrix.component }}:${VERSION_WITHOUT_PREFIX}
108-
109-
# Also update "latest" image if tagged commit is pushed to stable branch
110-
HIGHEST_SEMVER_TAG=$(get_tag_release -m)
111-
echo "Only push to latest tag if tag is the highest semver version $HIGHEST_SEMVER_TAG"
112-
113-
if [ "${VERSION_WITHOUT_PREFIX}" = "${HIGHEST_SEMVER_TAG:1}" ]
114-
then
115-
docker tag gcr.io/kf-feast/feast-${{ matrix.component }}:${GITHUB_SHA} gcr.io/kf-feast/feast-${{ matrix.component }}:latest
116-
docker push gcr.io/kf-feast/feast-${{ matrix.component }}:latest
117-
fi
101+
docker push gcr.io/kf-feast/feast-${{ matrix.component }}:latest
118102
fi
119103
120104
publish-helm-charts:

0 commit comments

Comments
 (0)