49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
name: Update_CalVer
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
# Fetch the full history
|
|
fetch-depth: 0
|
|
ref: main
|
|
|
|
- name: Calculate version
|
|
id: version
|
|
run: |
|
|
YEAR=$(date +%Y)
|
|
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
|
|
run: |
|
|
sed -i "s/subgen_version =.*/subgen_version = '${{ env.VERSION }}'/" subgen.py
|
|
|
|
- name: Amend commit with version update
|
|
env:
|
|
GIT_AUTHOR_NAME: "McCloudS"
|
|
GIT_AUTHOR_EMAIL: "scott@mccloud.dev"
|
|
run: |
|
|
git config user.name "${GIT_AUTHOR_NAME}"
|
|
git config user.email "${GIT_AUTHOR_EMAIL}"
|
|
|
|
git add subgen.py
|
|
git commit --amend --reuse-message=HEAD --author="${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}>"
|
|
|
|
# Pull any remote changes
|
|
git pull --rebase origin main # Use --rebase to avoid a merge commit
|
|
|
|
# Push the amended commit
|
|
git push origin HEAD:main
|