Skip to content

dns gateway: create manifest for every filter (#537) #34

dns gateway: create manifest for every filter (#537)

dns gateway: create manifest for every filter (#537) #34

# Copyright Built On Envoy
# SPDX-License-Identifier: Apache-2.0
# The full text of the Apache license is available in the LICENSE file at
# the root of the repo.
name: Auto Release Extensions
on:
push:
branches:
- main
- release/**
paths:
- 'extensions/*/manifest.yaml'
env:
OCI_REGISTRY: ghcr.io/tetratelabs
jobs:
detect-version-changes:
runs-on: ubuntu-latest
outputs:
changed-extensions: ${{ steps.detect.outputs.extensions }}
has-changes: ${{ steps.detect.outputs.has-changes }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 2 # Need at least 2 commits to compare
- name: Detect version changes
id: detect
run: |
set -e
echo "Checking for version changes in manifest.yaml files..."
# Array to store changed extensions
changed_extensions="[]"
has_changes="false"
# Get all changed manifest.yaml files in top-level extension directories
changed_manifests=$(git diff --name-only HEAD~1 HEAD | grep '^extensions/[^/]*/manifest.yaml$' || true)
if [ -z "$changed_manifests" ]; then
echo "No manifest.yaml files changed"
echo "extensions=$changed_extensions" >> "$GITHUB_OUTPUT"
echo "has-changes=$has_changes" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Changed manifests: $changed_manifests"
# Check each changed manifest for version changes or new extensions
for manifest in $changed_manifests; do
echo "Checking $manifest..."
# Extract extension path (directory name)
ext_path=$(echo "$manifest" | cut -d'/' -f2)
# Read name and type from manifest
ext_name=$(yq '.name' "$manifest")
type=$(yq '.type' "$manifest")
# Get old and new versions
# For new extensions, old_version will be empty string
old_version=$(git show HEAD~1:"$manifest" 2>/dev/null | yq '.version' || echo "")
new_version=$(yq '.version' "$manifest")
echo "Extension: $ext_name (type=$type, path=$ext_path)"
echo "Old version: ${old_version:-<new extension>}"
echo "New version: $new_version"
# Check if version changed or this is a new extension, and new version matches x.y.z
if [ "$old_version" != "$new_version" ] && echo "$new_version" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
if [ -z "$old_version" ]; then
echo "New extension detected: $ext_name (version: $new_version)"
else
echo "Version changed for $ext_name: $old_version -> $new_version"
fi
# Add to changed extensions list
changed_extensions=$(echo "$changed_extensions" | jq -c \
--arg name "$ext_name" \
--arg type "$type" \
--arg path "$ext_path" \
'. + [{name: $name, type: $type, path: $path}]')
has_changes="true"
else
echo "Skipping $ext_name: old version: ${old_version:-<none>}, new version: $new_version"
fi
done
echo "Changed extensions: $changed_extensions"
echo "extensions=$changed_extensions" >> "$GITHUB_OUTPUT"
echo "has-changes=$has_changes" >> "$GITHUB_OUTPUT"
release-extensions:
needs: detect-version-changes
if: needs.detect-version-changes.outputs.has-changes == 'true'
uses: ./.github/workflows/release-extensions-impl.yaml
with:
extensions: ${{ needs.detect-version-changes.outputs.changed-extensions }}
secrets: inherit