Update calver.yml

This commit is contained in:
McCloudS
2024-11-17 19:54:18 -07:00
parent 3b46c300ff
commit a636d74603
2 changed files with 18 additions and 16 deletions

View File

@@ -14,31 +14,33 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
fetch-depth: 0 # Fetch only the latest commit initially
fetch-depth: 1
ref: main
- name: Generate Monthly Commit Count - name: Fetch commits for this month
id: commit_count
run: | run: |
# Get the current year and month # Fetch commits starting from the first day of the current month
YEAR=$(date +%Y) YEAR=$(date +%Y)
MONTH=$(date +%m) MONTH=$(date +%m)
git fetch --shallow-since="$YEAR-$MONTH-01"
# Count commits from the start of the current month - name: Calculate version
COMMIT_COUNT=$(git rev-list --count HEAD --since="$YEAR-$MONTH-01") id: version
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_ENV
- name: Set Calver Version
id: setcalver
run: | run: |
# Combine year, month, and commit count for the version # Calculate the commit count for this month
VERSION=$(date +%Y.%m).${{ env.commit_count }} YEAR=$(date +%Y)
echo "package_version=$VERSION" >> $GITHUB_ENV MONTH=$(date +%m)
COMMIT_COUNT=$(git rev-list --count HEAD --since="$YEAR-$MONTH-01")
echo "COMMIT_COUNT=$COMMIT_COUNT"
echo "VERSION=${YEAR}.${MONTH}.${COMMIT_COUNT}" >> $GITHUB_ENV
- name: Update version file - name: Update version file
run: | run: |
sed -i "s/subgen_version =.*/subgen_version = '${{ env.package_version }}'/" subgen.py # Update subgen.py with the calculated version
sed -i "s/subgen_version =.*/subgen_version = '${{ env.VERSION }}'/" subgen.py
- name: Amend commit with version update - name: Amend commit with version update
env: env:

View File

@@ -1,4 +1,4 @@
subgen_version = '2024.11.18.555' subgen_version = '2024.11.21'
from datetime import datetime from datetime import datetime
import subprocess import subprocess