Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/auto_release_on_json_schema_change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Auto Release on Schema Changes

on:
pull_request:

@jcpitre jcpitre Dec 23, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider using a push to master trigger instead?
See this as an example
One advantage is that you can restrict the trigger only to changes in specified folders.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — using a push trigger with paths would work, but I opted for a pull_request: closed trigger to ensure releases only happen after an explicit PR merge and to avoid accidental releases from direct pushes.

types: [closed]
branches:
- master

jobs:
release:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Checkout repository (full history + tags)
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Detect schema changes in versioned folders
run: |
BASE_SHA="${{ github.event.pull_request.base.sha }}"
MERGE_SHA="${{ github.sha }}"

echo "Base SHA: $BASE_SHA"
echo "Merge SHA: $MERGE_SHA"

changed_files=$(git diff --name-only "$BASE_SHA" "$MERGE_SHA")

echo "Changed files:"
echo "$changed_files"

# Root-level vX.X folders only
if echo "$changed_files" | grep -qE '^v[0-9]+\.[0-9]+/'; then
echo "Schema changes detected in versioned folders."
echo "release_needed=true" >> $GITHUB_ENV
else
echo "No schema changes detected."
echo "release_needed=false" >> $GITHUB_ENV
fi

- name: Determine next version
if: env.release_needed == 'true'
run: |
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $latest_tag"

new_version=$(echo "$latest_tag" | awk -F. -v OFS=. '{$NF++; print}')
echo "New version: $new_version"

echo "new_version=$new_version" >> $GITHUB_ENV

- name: Create GitHub Release
if: env.release_needed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "$new_version" \
--title "Release $new_version" \
--notes "Automatic release triggered by changes to versioned schema folders."