Files
Transcriptarr/.github/workflows/calver.yml
2024-11-17 19:50:08 -07:00

59 lines
1.6 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@v2
with:
fetch-depth: 0
- name: Generate Monthly Commit Count
id: commit_count
run: |
# Get the current year and month
YEAR=$(date +%Y)
MONTH=$(date +%m)
# Count commits from the start of the current month
COMMIT_COUNT=$(git rev-list --count HEAD --since="$YEAR-$MONTH-01")
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_ENV
- name: Set Calver Version
id: setcalver
run: |
# Combine year, month, and commit count for the version
VERSION=$(date +%Y.%m).${{ env.commit_count }}
echo "package_version=$VERSION" >> $GITHUB_ENV
- name: Update version file
run: |
sed -i "s/subgen_version =.*/subgen_version = '${{ env.package_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}"
# Stage the modified file
git add subgen.py
# 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