Files
Transcriptarr/.github/workflows/calver.yml
2025-02-06 10:43:57 -07:00

54 lines
1.5 KiB
YAML

name: Update_CalVer
on:
push:
branches:
- 'main'
paths:
- 'subgen.py'
- 'launcher.py'
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- 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 and rebase. Handle potential conflicts.
git pull --rebase origin main || {
echo "Rebase failed! Resolving conflicts..."
git rebase --abort # Abort the rebase
exit 1 # Fail the job (optional)
}
# Push the amended commit
git push origin HEAD:main