Remove .gitlab-ci.yml (#2069) #3
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: Release Charts | |
on: | |
push: | |
branches: | |
- master | |
env: | |
REGISTRY_IMAGE: docker.io/kubeflow/spark-operator | |
jobs: | |
build-skip-check: | |
runs-on: ubuntu-latest | |
outputs: | |
image_changed: ${{ steps.skip-check.outputs.image_changed }} | |
chart_changed: ${{ steps.skip-check.outputs.chart_changed }} | |
app_version_tag: ${{ steps.skip-check.outputs.app_version_tag }} | |
chart_version_tag: ${{ steps.skip-check.outputs.chart_version_tag }} | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if build should be skipped | |
id: skip-check | |
run: | | |
app_version_tag=$(cat charts/spark-operator-chart/Chart.yaml | grep "appVersion: .*" | cut -c13-) | |
chart_version_tag=$(cat charts/spark-operator-chart/Chart.yaml | grep "version: .*" | cut -c10-) | |
# Initialize flags | |
image_changed=false | |
chart_changed=false | |
if ! git rev-parse -q --verify "refs/tags/$app_version_tag"; then | |
image_changed=true | |
git tag $app_version_tag | |
git push origin $app_version_tag | |
echo "Spark-Operator Docker Image new tag: $app_version_tag released" | |
fi | |
if ! git rev-parse -q --verify "refs/tags/spark-operator-chart-$chart_version_tag"; then | |
chart_changed=true | |
git tag spark-operator-chart-$chart_version_tag | |
git push origin spark-operator-chart-$chart_version_tag | |
echo "Spark-Operator Helm Chart new tag: spark-operator-chart-$chart_version_tag released" | |
fi | |
echo "image_changed=${image_changed}" >> "$GITHUB_OUTPUT" | |
echo "chart_changed=${chart_changed}" >> "$GITHUB_OUTPUT" | |
echo "app_version_tag=${app_version_tag}" >> "$GITHUB_OUTPUT" | |
echo "chart_version_tag=${chart_version_tag}" >> "$GITHUB_OUTPUT" | |
release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-skip-check | |
if: needs.build-skip-check.outputs.image_changed == 'true' | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
- linux/arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
echo "SCOPE=${platform//\//-}" >> $GITHUB_ENV | |
- name: Set up QEMU | |
timeout-minutes: 1 | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
with: | |
version: v3.14.3 | |
- name: Login to Packages Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and Push Spark-Operator Docker Image to Docker Hub | |
id: build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
cache-to: type=gha,mode=max,scope=${{ env.SCOPE }} | |
cache-from: type=gha,scope=${{ env.SCOPE }} | |
push: true | |
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export digest | |
run: | | |
mkdir -p /tmp/digests | |
digest="${{ steps.build.outputs.digest }}" | |
touch "/tmp/digests/${digest#sha256:}" | |
- name: Upload digest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: digests-${{ env.PLATFORM_PAIR }} | |
path: /tmp/digests/* | |
if-no-files-found: error | |
retention-days: 1 | |
publish-image: | |
runs-on: ubuntu-latest | |
needs: | |
- release | |
- build-skip-check | |
if: needs.build-skip-check.outputs.image_changed == 'true' | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: digests-* | |
path: /tmp/digests | |
merge-multiple: true | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY_IMAGE }} | |
tags: ${{ needs.build-skip-check.outputs.app_version_tag }} | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create manifest list and push | |
working-directory: /tmp/digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} | |
publish-chart: | |
runs-on: ubuntu-latest | |
if: needs.build-skip-check.outputs.chart_changed == 'true' | |
needs: | |
- build-skip-check | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
with: | |
version: v3.14.3 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Release Spark-Operator Helm Chart | |
uses: helm/[email protected] | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_RELEASE_NAME_TEMPLATE: "spark-operator-chart-{{ .Version }}" |