Skip to content

build(2.0.0): merge release into main (#107) #14

build(2.0.0): merge release into main (#107)

build(2.0.0): merge release into main (#107) #14

Workflow file for this run

###############################################################
# Copyright (c) 2024 BMW Group AG
# Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
name: Release
on:
workflow_dispatch:
push:
paths:
- 'charts/**'
branches:
- main
jobs:
release-helm-chart:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
app-version: ${{ steps.app-version.outputs.current }}
version-check: ${{ steps.version-check.outputs.exists }}
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4
- name: Update helm dependencies for dim
run: |
cd charts/dim
helm repo add bitnami https://charts.bitnami.com/bitnami
helm dependency update
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_SKIP_EXISTING: "true"
- name: Get current appVersion
id: app-version
run: |
current=$(cat ./charts/dim/Chart.yaml | grep "appVersion:" | head -1 | cut -d ":" -d " " -f2)
echo "current=$current" >> $GITHUB_OUTPUT
echo "Exported $current appVersion"
- name: Check for previous version
id: version-check
run: |
exists=$(git tag -l "v${{ steps.app-version.outputs.current }}")
if [[ -n "$exists" ]]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
release-images:
needs: release-helm-chart
if: needs.release-helm-chart.outputs.version-check == 'false'
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
include:
- image: ghcr.io/${{ github.repository }}_dim-service
dockerfile: ./docker/Dockerfile-dim-service
- image: ghcr.io/${{ github.repository }}_dim-migrations
dockerfile: ./docker/Dockerfile-dim-migrations
- image: ghcr.io/${{ github.repository }}_dim-processes-worker
dockerfile: ./docker/Dockerfile-dim-processes-worker
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
# Create SemVer or ref tags dependent of trigger event
- name: Docker meta
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: ${{ matrix.image }}
# Automatically prepare image tags; See action docs for more examples.
# semver patter will generate tags like these for example :1 :1.2 :1.2.3
tags: |
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest
type=semver,pattern={{version}},value=${{ needs.release-helm-chart.outputs.app-version }}
type=semver,pattern={{major}},value=${{ needs.release-helm-chart.outputs.app-version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.release-helm-chart.outputs.app-version }}
- name: Build and push Docker images
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
context: .
file: ${{ matrix.dockerfile }}
platforms: linux/amd64, linux/arm64
pull: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
create-tag:
needs: [release-helm-chart, release-images]
if: needs.release-helm-chart.outputs.version-check == 'false'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Create and push git tag
run: |
git tag v${{ needs.release-helm-chart.outputs.app-version }}
git push origin v${{ needs.release-helm-chart.outputs.app-version }}