build and publish docker images #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build and publish docker images | |
on: | |
workflow_dispatch: # Allows manual trigger of the workflow | |
inputs: | |
custom_version: # Optional input for a custom version | |
description: 'Custom version to publish (e.g., v1.2.3) -- only edit if you know what you are doing' | |
required: false | |
token: | |
description: 'Personal Access Token' | |
required: true | |
default: "" | |
type: string | |
jobs: | |
get-version: | |
if: github.repository == 'feast-dev/feast' | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_TOKEN: ${{ github.event.inputs.token }} | |
GIT_AUTHOR_NAME: feast-ci-bot | |
GIT_AUTHOR_EMAIL: [email protected] | |
GIT_COMMITTER_NAME: feast-ci-bot | |
GIT_COMMITTER_EMAIL: [email protected] | |
outputs: | |
release_version: ${{ steps.get_release_version.outputs.release_version }} | |
version_without_prefix: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} | |
highest_semver_tag: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get release version | |
id: get_release_version | |
run: | | |
if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then | |
VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$" | |
echo "Using custom version: ${{ github.event.inputs.custom_version }}" | |
if [[ ! "${{ github.event.inputs.custom_version }}" =~ $VERSION_REGEX ]]; then | |
echo "Error: custom_version must match semantic versioning (e.g., v1.2.3)." | |
exit 1 | |
fi | |
echo "::set-output name=release_version::${{ github.event.inputs.custom_version }}" | |
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
echo "Using tag reference: ${GITHUB_REF#refs/tags/}" | |
echo "::set-output name=release_version::${GITHUB_REF#refs/tags/}" | |
else | |
echo "Defaulting to branch name: ${GITHUB_REF#refs/heads/}" | |
echo "::set-output name=release_version::${GITHUB_REF#refs/heads/}" | |
fi | |
- name: Get release version without prefix | |
id: get_release_version_without_prefix | |
env: | |
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} | |
run: | | |
if [[ "${RELEASE_VERSION}" == v* ]]; then | |
echo "::set-output name=version_without_prefix::${RELEASE_VERSION:1}" | |
else | |
echo "::set-output name=version_without_prefix::${RELEASE_VERSION}" | |
fi | |
- name: Get highest semver | |
id: get_highest_semver | |
env: | |
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} | |
run: | | |
if [[ -n "${{ github.event.inputs.custom_version }}" ]]; then | |
HIGHEST_SEMVER_TAG="${{ github.event.inputs.custom_version }}" | |
echo "::set-output name=highest_semver_tag::$HIGHEST_SEMVER_TAG" | |
echo "Using custom version as highest semantic version: $HIGHEST_SEMVER_TAG" | |
else | |
source infra/scripts/setup-common-functions.sh | |
SEMVER_REGEX='^v[0-9]+\.[0-9]+\.[0-9]+(-([0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*))?$' | |
if echo "${RELEASE_VERSION}" | grep -P "$SEMVER_REGEX" &>/dev/null ; then | |
echo ::set-output name=highest_semver_tag::$(get_tag_release -m) | |
echo "Using infra/scripts/setup-common-functions.sh to generate highest semantic version: $HIGHEST_SEMVER_TAG" | |
fi | |
fi | |
- name: Check output | |
env: | |
RELEASE_VERSION: ${{ steps.get_release_version.outputs.release_version }} | |
VERSION_WITHOUT_PREFIX: ${{ steps.get_release_version_without_prefix.outputs.version_without_prefix }} | |
HIGHEST_SEMVER_TAG: ${{ steps.get_highest_semver.outputs.highest_semver_tag }} | |
run: | | |
echo $RELEASE_VERSION | |
echo $VERSION_WITHOUT_PREFIX | |
echo $HIGHEST_SEMVER_TAG | |
build-publish-docker-images: | |
runs-on: ubuntu-latest | |
needs: [get-version] | |
strategy: | |
matrix: | |
component: [feature-server, feature-server-java, feature-transformation-server, feast-helm-operator, feast-operator] | |
env: | |
MAVEN_CACHE: gs://feast-templocation-kf-feast/.m2.2020-08-19.tar | |
REGISTRY: feastdev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Authenticate to Google Cloud | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
- name: Set up gcloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Use gcloud CLI | |
run: gcloud info | |
- run: gcloud auth configure-docker --quiet | |
- name: Build image | |
run: | | |
make build-${{ matrix.component }}-docker REGISTRY=${REGISTRY} VERSION=${VERSION_WITHOUT_PREFIX} | |
env: | |
RELEASE_VERSION: ${{ needs.get-version.outputs.release_version }} | |
VERSION_WITHOUT_PREFIX: ${{ needs.get-version.outputs.version_without_prefix }} | |
HIGHEST_SEMVER_TAG: ${{ needs.get-version.outputs.highest_semver_tag }} | |
- name: Push versioned images | |
env: | |
RELEASE_VERSION: ${{ needs.get-version.outputs.release_version }} | |
VERSION_WITHOUT_PREFIX: ${{ needs.get-version.outputs.version_without_prefix }} | |
HIGHEST_SEMVER_TAG: ${{ needs.get-version.outputs.highest_semver_tag }} | |
run: | | |
make push-${{ matrix.component }}-docker REGISTRY=${REGISTRY} VERSION=${VERSION_WITHOUT_PREFIX} | |
echo "Only push to latest tag if tag is the highest semver version $HIGHEST_SEMVER_TAG" | |
if [ "${VERSION_WITHOUT_PREFIX}" = "${HIGHEST_SEMVER_TAG:1}" ] | |
then | |
docker tag feastdev/${{ matrix.component }}:${VERSION_WITHOUT_PREFIX} feastdev/${{ matrix.component }}:latest | |
docker push feastdev/${{ matrix.component }}:latest | |
fi | |