From 8b0396d957dfe9feddf5c2457745b611bd97e6be Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Thu, 6 Feb 2025 10:22:16 -0700 Subject: [PATCH] Update calver.yml --- .github/workflows/calver.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/calver.yml b/.github/workflows/calver.yml index 7f5c095..eab7ce4 100644 --- a/.github/workflows/calver.yml +++ b/.github/workflows/calver.yml @@ -16,23 +16,17 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - # Fetch only the latest commit initially - fetch-depth: 1 + # Fetch the full history, it's important here + fetch-depth: 0 ref: main - - name: Fetch commits for this month - run: | - # Fetch commits starting from the first day of the current month - YEAR=$(date +%Y) - MONTH=$(date +%m) - git fetch --shallow-since="$YEAR-$MONTH-01" - - name: Calculate version id: version run: | # Calculate the commit count for this month YEAR=$(date +%Y) MONTH=$(date +%m) + # count commits since start of the month, limiting scope COMMIT_COUNT=$(git rev-list --count HEAD --since="$YEAR-$MONTH-01") echo "COMMIT_COUNT=$COMMIT_COUNT" echo "VERSION=${YEAR}.${MONTH}.${COMMIT_COUNT}" >> $GITHUB_ENV @@ -56,5 +50,10 @@ jobs: # Amend the most recent commit, reusing the previous commit message git commit --amend --reuse-message=HEAD --author="${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>" - # Push the amended commit - git push --force + # Attempt a regular push first. If it fails because of remote changes, use --force-with-lease cautiously. + git push origin HEAD:main + + # Alternative: Use --force-with-lease if a regular push fails + # This is much safer than --force, but still requires care + # If this fails as well (e.g., very recent conflict), you'll need manual intervention. + # git push --force-with-lease origin HEAD:main