Skip to content

Conversation

@graycreate
Copy link
Member

@graycreate graycreate commented Sep 9, 2025

Summary

This PR implements a single source of truth release system where config.gradle is the ONLY trigger for releases.

✨ Key Design: config.gradle as Single Source

NO tag triggers - Only config.gradle changes trigger releases:

  • ✅ Update version in config.gradle → Auto release
  • ❌ Push tag manually → Nothing happens (removed)

How It Works

graph LR
    A[Update config.gradle] --> B[Push to main]
    B --> C[Detect version increase]
    C --> D[Auto-create tag]
    D --> E[Build & Release]
    
    F[Manual dispatch] --> E
Loading

Implementation Details

  1. Trigger: Only on config.gradle changes to main branch
  2. Version Check: Compares with previous commit
  3. Auto Tag: Creates tag if version increased
  4. Release: Builds and publishes automatically
  5. Safety: Prevents duplicate tags/releases

Fixes Copilot Comments

First commit handling: Proper HEAD~1 existence check
Robust parsing: Extended regex for gradle files
Race condition prevention: Tag existence verification

Usage

Primary Method: Version-driven

# Edit config.gradle
versionCode: 235
versionName: "2.3.5"

# Commit and push
git add config.gradle
git commit -m "chore: bump version to 2.3.5"
git push origin main

# Automatically:
# 1. Creates tag v2.3.5
# 2. Builds APK/AAB
# 3. Uploads to Google Play
# 4. Creates GitHub release

Manual Re-run

Use GitHub Actions UI for re-running failed releases

Benefits

  • 🎯 Single source of truth - config.gradle controls everything
  • 🚫 No tag management - Tags are auto-created, not manual
  • No version mismatches - Version always synced
  • 🔒 No accidental releases - Only version increases trigger
  • 📦 Simple workflow - Just update version and push

Testing

  1. Update version in config.gradle
  2. Push to main
  3. Watch automatic release process

This eliminates all version sync issues by having ONE authoritative source!

- Automatically creates git tags when version changes in config.gradle
- Monitors config.gradle changes on main branch
- Creates annotated tags in format v{version}
- Triggers release workflow automatically via tag creation
- Prevents duplicate tags and provides clear status summaries
Copilot AI review requested due to automatic review settings September 9, 2025 23:26

This comment was marked as outdated.

- Removes separate version-change-trigger.yml workflow
- Adds auto version update step directly in release.yml prepare job
- Automatically updates config.gradle when tag version differs
- Ensures all build jobs use updated version from main branch
- Prevents version mismatch issues like the v2.3.4 incident
- Simplifies release process - just create tag and everything updates automatically
@graycreate graycreate changed the title feat: Add automatic version tagging workflow refactor: Integrate auto version update into release workflow Sep 9, 2025
- Add release-on-version-change.yml that monitors config.gradle changes
- Auto-creates tags when version is updated in config.gradle
- Simplifies release.yml by removing version update logic
- Better workflow: update version -> auto tag -> auto release
@graycreate graycreate changed the title refactor: Integrate auto version update into release workflow feat: Version-change-triggered release workflow Sep 9, 2025
- Merge version change detection directly into release.yml
- Remove separate release-on-version-change.yml workflow
- Fix Copilot review comments:
  - Handle first commit case properly (no HEAD~1)
  - Use more robust regex patterns for gradle parsing
  - Add tag existence check to prevent race conditions
- Workflow now triggers on:
  - Tag push (v*)
  - config.gradle changes on main branch
  - Manual workflow dispatch
- Auto-creates tags when version increases in config.gradle
@graycreate graycreate changed the title feat: Version-change-triggered release workflow refactor: Integrate version monitoring into release workflow Sep 10, 2025
- Remove tag push trigger completely
- Keep only config.gradle as trigger source
- Auto-create tags when version increases
- Prevent duplicate releases with tag existence check
- Manual workflow dispatch still available for re-runs

This ensures config.gradle is the ONLY source of truth for releases
@graycreate graycreate changed the title refactor: Integrate version monitoring into release workflow feat: Single source of truth release - config.gradle triggered Sep 10, 2025
@graycreate graycreate requested a review from Copilot September 10, 2025 00:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a single source of truth release system where changes to config.gradle on the main branch automatically trigger releases, eliminating the need for manual tag management.

  • Changes trigger mechanism from tag-based to config.gradle file changes on main branch
  • Adds version comparison logic to detect version increases and auto-create tags
  • Updates all jobs to conditionally run based on version change detection

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if: github.event_name == 'push'
run: |
# Get current version from config.gradle
CURRENT_VERSION=$(grep versionName config.gradle | sed -E 's/.*versionName:\s*"([^"]+)".*/\1/')
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The grep command will fail silently if no match is found, resulting in an empty CURRENT_VERSION. This could lead to incorrect version comparison logic. Add error handling to ensure the version is properly extracted.

Copilot uses AI. Check for mistakes.
echo "Current: v$CURRENT_VERSION (code: $CURRENT_CODE)"
# Check if version increased
if [ -n "$CURRENT_VERSION" ] && [ "$CURRENT_CODE" -gt "$PREV_CODE" ]; then
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The condition only checks if CURRENT_VERSION is non-empty but doesn't validate CURRENT_CODE. If CURRENT_CODE extraction fails and becomes empty, the numeric comparison will fail. Add validation for both CURRENT_CODE and ensure it's a valid number before the comparison.

Copilot uses AI. Check for mistakes.
run: |
# Extract version code from config.gradle
VERSION_CODE=$(grep "versionCode:" config.gradle | sed 's/.*versionCode: \([0-9]*\).*/\1/')
VERSION_CODE=$(grep "versionCode:" config.gradle | sed -E 's/.*versionCode:\s*([0-9]+).*/\1/')
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

This version code extraction logic is duplicated from line 59. Consider extracting this into a reusable function or using the already computed value from the check_version step to avoid duplication and potential inconsistencies.

Copilot uses AI. Check for mistakes.
Comment on lines 122 to 125
if git ls-remote --tags origin | grep -q "refs/tags/${TAG_NAME}$"; then
echo "⚠️ Tag $TAG_NAME already exists"
exit 0
fi
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

Exiting with code 0 when a tag already exists will mark the step as successful, but subsequent jobs expecting a new tag to be created may fail or behave unexpectedly. Consider using a different exit code or setting an output variable to communicate this state to dependent jobs.

Copilot uses AI. Check for mistakes.
- Add error handling for grep commands with validation
- Validate version code is a valid number before comparison
- Remove duplicate version code extraction logic
- Fix tag exists exit code to use output variables instead

All 4 new Copilot comments have been addressed with proper error handling
@graycreate graycreate merged commit dea77e5 into main Sep 10, 2025
5 checks passed
@graycreate graycreate deleted the feature/auto-version-tagging branch September 10, 2025 00:36
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.

2 participants