Weekly Tag #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 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 describe --tags --abbrev=0 2>/dev/null || 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." | |
else | |
echo "changes=true" >> $GITHUB_OUTPUT | |
latest_version=${latest_tag#v} | |
echo "latest_version=$latest_version" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- 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 https://x-access-token:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/${{ github.repository }}.git v${{ steps.calc_version.outputs.new_version }} |