Skip to content

Fix CI manual tag versioning to use tag creation date - #757

Merged
Arlodotexe merged 3 commits into
mainfrom
fix/ci-tag-versioning-date-extraction
Oct 28, 2025
Merged

Arlodotexe merged 3 commits into
mainfrom
fix/ci-tag-versioning-date-extraction

Conversation

@Arlodotexe

@Arlodotexe Arlodotexe commented Oct 28, 2025 •

Copy link
Copy Markdown
Member

Summary

Fixes issue where manually created tags produce packages with incorrect dates. Tag release/weekly/251027 (created 10/27) was producing packages dated 251021 (6-day mismatch).

Root Cause

The CI workflow used git log -1 --format=%cd without a tag reference, which extracts the commit date instead of the date from the tag name for tagged builds.

Changes

Tag Builds (Fixed)

  • Now extracts date directly from tag name using string replacement: refs/tags/release/weekly/YYMMDD → YYMMDD
  • Only sets VERSION_DATE environment variable for tag builds
  • Allows intentional back-dating or post-dating of releases by using the date in the tag name
  • Example: Tag refs/tags/release/weekly/251027 → packages dated 251027

Non-Tag Builds (Main/PR - No Change)

  • VERSION_DATE environment variable is not set
  • Build script defaults to current date via (Get-Date -UFormat %y%m%d)
  • Behavior unchanged: packages are dated by build time

Build Script Invocation

  • -DateForVersion parameter now conditionally passed only when VERSION_DATE is set
  • Uses GitHub Actions expression: ${{ env.VERSION_DATE != '' && format('-DateForVersion {0}', env.VERSION_DATE) || '' }}

Implementation

- name: Format Date/Time for Package Version (Tag builds only)
  if: ${{ startsWith(github.ref, 'refs/tags/') }}
  run: |
    # Extract date from tag name (e.g., refs/tags/release/weekly/251027 -> 251027)
    # Non-tag builds: VERSION_DATE not set, script defaults to current date
    $dateString = "${{ github.ref }}" -replace '^refs/tags/release/weekly/', ''
    echo "VERSION_DATE=$dateString" >> $env:GITHUB_ENV

Rationale

Extracting from the tag name (rather than tag creation timestamp) allows for intentional back-dating or post-dating of releases, matching the pattern used in the main CommunityToolkit/Windows repository for rel/* branches.

- Tag builds: Extract date from tag creation date using git for-each-ref (fixes issue where tag release/weekly/251027 created 10/27 produced packages dated 251021 from commit date)
- Non-tag builds: Omit VERSION_DATE parameter, allowing script to default to current date (Get-Date -UFormat %y%m%d)
- Conditionally pass -DateForVersion parameter only when VERSION_DATE is set

Root cause: Original code used 'git log -1 --format=%cd' without tag reference, extracting commit date instead of tag creation date for all build scenarios.
Comment thread .github/workflows/build.yml Resolved
@michael-hawker

Copy link
Copy Markdown
Member

@Arlodotexe also don't forget to remove the chron job from the other workflow for now too.

@Arlodotexe

Arlodotexe commented Oct 28, 2025 •

Copy link
Copy Markdown
Member Author

@Arlodotexe also don't forget to remove the chron job from the other workflow for now too.

Since we know the scheduled job can't trip a build even though it creates a tag, should we just remove the job entirely?

@michael-hawker

Copy link
Copy Markdown
Member

@Arlodotexe I suppose so at this point, worst case we have it in the history.

@Arlodotexe
Arlodotexe enabled auto-merge October 28, 2025 20:52

@michael-hawker michael-hawker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LTGM

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