Skip to content

Weekly Tag

Weekly Tag #26

Workflow file for this run

name: Weekly Tag
on:
schedule:
- cron: "0 0 * * 1" # Run every Monday at 00:00 UTC
workflow_dispatch: # Allow manual triggers
jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0 # Fetch all history for all tags and branches
- name: Check for changes and get latest tag
id: check_changes
run: |
latest_tag=$(git tag | sort -r | head -n 1 || echo "")
if [ -z "$latest_tag" ]; then
echo "No previous tag found. Will create first tag."
echo "changes=true" >> $GITHUB_OUTPUT
echo "latest_version=0" >> $GITHUB_OUTPUT
else
if git diff --quiet $latest_tag HEAD; then
echo "No changes since last tag."
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
latest_version=${latest_tag#v}
echo "latest_version=$latest_version" >> $GITHUB_OUTPUT
fi
fi
- name: Exit if no changes
if: steps.check_changes.outputs.changes != 'true'
run: |
echo "No changes detected since last tag. Exiting workflow."
exit 78
- name: Calculate new version
id: calc_version
if: steps.check_changes.outputs.changes == 'true'
run: |
latest_version="${{ steps.check_changes.outputs.latest_version }}"
new_version=$((latest_version + 1))
echo "new_version=$new_version" >> $GITHUB_OUTPUT
- name: Create and push new tag
if: steps.check_changes.outputs.changes == 'true'
run: |
git config user.name github-actions
git config user.email [email protected]
git tag v${{ steps.calc_version.outputs.new_version }}
git push origin v${{ steps.calc_version.outputs.new_version }}