diff --git a/.github/workflows/helm-release.yml b/.github/workflows/helm-release.yml index 5611486..98592a8 100644 --- a/.github/workflows/helm-release.yml +++ b/.github/workflows/helm-release.yml @@ -28,7 +28,49 @@ jobs: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Update Chart AppVersion + env: + ACTION_TRIGGER: ${{github.event_name}} + run: | + CHART_PATH="charts/sogo/Chart.yaml" + + # Update chart version + + # Extract the current version from the file + CURRENT_VERSION=$(grep -Eo 'version: [0-9]+\.[0-9]+\.[0-9]+' "$CHART_PATH" | awk '{print $2}') + + # If no version is found, exit with an error + if [ -z "$CURRENT_VERSION" ]; then + echo "No version found in the file!" + exit 0 + fi + + # Split the version into major, minor, and patch + IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION" + MAJOR=${VERSION_PARTS[0]} + MINOR=${VERSION_PARTS[1]} + PATCH=${VERSION_PARTS[2]} + + if [ "$ACTION_TRIGGER" = "workflow_dispatch" ]; then + # Increment the version + PATCH=$((PATCH + 1)) + else + MINOR=$((MINOR + 1)) + fi + + # Form the new version + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + + # Update the file with the new version + sed -i 's/version: '"$CURRENT_VERSION"'/version: '"$NEW_VERSION"'/' "$CHART_PATH" + - name: Commit files and push it + run: | + git add . + git commit -m "chore: bump chart version" + git push + # See https://github.com/helm/chart-releaser-action/issues/6 - name: Set up Helm uses: azure/setup-helm@v3.5 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 410717c..48c0cda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,6 +69,11 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + - name: Docker - GHCR Login uses: docker/login-action@v3 with: @@ -115,6 +120,22 @@ jobs: generate_release_notes: true body: | SOGo Update: https://github.com/Alinto/sogo/releases/tag/SOGo-${{ needs.check_versions.outputs.base_version }} + + - name: Update Chart AppVersion + env: + APP_VERSION: ${{needs.check_versions.outputs.base_version}} + DOCKER_REVISION: ${{needs.check_versions.outputs.next_revision}} + run: | + CHART_PATH="charts/sogo/Chart.yaml" + + sed -i 's|sonroyaalmerol/docker-sogo:[^ ]*|sonroyaalmerol/docker-sogo:'"$APP_VERSION"'-'"$DOCKER_REVISION"'|g' "$CHART_PATH" + sed -i 's/^appVersion:.*$/appVersion: '"$APP_VERSION"'/' "$CHART_PATH" + + - name: Commit files and push it + run: | + git add . + git commit -m "chore: bump container versions in chart" + git push release_helm: needs: release