Skip to content

Conversation

@ssestak
Copy link
Contributor

@ssestak ssestak commented Jul 25, 2025

Universal Detect Changes and Generate Changelog Action

This action detects changes since the last successful build and generates a changelog based on merge commits. It's designed to be universal, handling various edge cases and providing flexible configuration options.

Key Features

  • Detects changes between builds using cache-based tracking
  • Generates changelog from merge commit messages
  • Smart build skipping when no relevant changes detected
  • Fallback mechanisms for first runs or cache misses
  • Debug mode for troubleshooting

Inputs

Name Description Required Default
depth Git history depth to fetch No 100
debug Enable debug logging No false
time_value Lookback time amount when no previous build found No 24
time_unit Lookback time unit (hours/days/weeks/months) No hours

Outputs

Name Description
skip_build Boolean indicating if build should be skipped
changelog Generated changelog string from merge commits
merged_branches List of merged branch names

How It Works

  1. Cache Management:

    • Stores the last successful build commit in cache
    • Uses run-number based cache keys
    • Falls back to previous 5 runs if immediate cache miss
  2. Change Detection:

    • First attempts to use cached last build commit
    • If cache miss, falls back to time-based detection
    • Checks for merge commits between last build and current HEAD
  3. Build Skip Logic:

    • Skips if no new merge commits since last build
    • Always builds on first run or cache miss
    • Uses time window fallback for determining changes
  4. Changelog Generation:

    • Extracts messages from merge commits
    • Formats them into a readable changelog
    • Includes list of merged branch names

Edge Cases Handled

  1. First Run:

    • No previous cache exists
    • Uses time-based window to find oldest merge commit
    • Generates changelog from all relevant commits
  2. Cache Misses:

    • Tries last 5 run numbers sequentially
    • Falls back to time-based detection if no cache hit
    • Ensures continuous operation even after cache purges
  3. Rebased History:

    • Detects if cached commit no longer exists
    • Falls back to time-based window
    • Prevents failures due to force pushes
  4. No Changes:

    • Properly handles cases with no new merge commits
    • Sets skip_build to true
    • Provides empty changelog

Example Usage

- name: Use Composite Action - Detect changes and get changelog
      id: detect_changes
      uses: futuredapp/.github/.github/actions/universal-detect-changes-and-generate-changelog@main
      with:
        depth: 200
        debug: true
        time_value: "2"
        time_unit: "days"

Debug Mode

When debug: true, the action provides detailed logging:

  • Cache key attempts and results
  • Git command outputs
  • Commit range calculations
  • Changelog generation process

This action is designed to be reliable and maintainable, with clear error handling and fallback mechanisms for various edge cases that might occur in real-world CI/CD pipelines.

Šimon Šesták added 20 commits July 26, 2025 00:39
# Conflicts:
#	.github/workflows/ios-selfhosted-build.yml
If we making last commit from git history instead of cache the last commit should take place in changelog as well
This approach should fix edge case when developer create a new build during the day. Then it will create a new build which he cancel. And after that will try to create a 3rd build. In the old version it will create a new changelog with features which were previously builded that day. With this approach it should not since it should hit the cache created that day.
@ssestak ssestak force-pushed the feature/Changelog branch from 68a881a to 4ae665b Compare July 31, 2025 15:35
@ssestak ssestak force-pushed the feature/Changelog branch from a083833 to 78ed688 Compare July 31, 2025 15:39
@ssestak ssestak merged commit 9dbef2c into main Aug 4, 2025
1 check passed
@ssestak ssestak deleted the feature/Changelog branch August 4, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants