@@ -41,118 +41,7 @@ jobs:
4141 - name : Set up Python
4242 uses : actions/setup-python@v5
4343 with :
44- python-version-file : ' .python-version'
45- cache : pip
46-
47- - name : Install dependencies
48- run : |
49- python -m pip install --upgrade pip
50- pip install pyyaml
51-
52- - name : Update version metadata (if triggered by tag)
53- if : steps.extract_version.outputs.is_tag == 'true'
54- env :
55- TAG_VERSION : ${{ steps.extract_version.outputs.version }}
56- run : |
57- python -m quadriga.metadata.update_version_from_tag
58-
59- - name : Update metadata files
60- run : python -m quadriga.metadata.run_all
61-
62- - name : Check if files changed
63- id : check_changes
64- run : |
65- if git diff --quiet metadata.yml && git diff --quiet CITATION.bib && git diff --quiet CITATION.cff; then
66- echo "changes_detected=false" >> $GITHUB_OUTPUT
67- else
68- echo "changes_detected=true" >> $GITHUB_OUTPUT
69- fi
70-
71- - name : Commit changes (regular push)
72- if : steps.check_changes.outputs.changes_detected == 'true' && steps.extract_version.outputs.is_tag == 'false'
73- run : |
74- git config --local user.email "github-actions[bot]@users.noreply.github.com"
75- git config --local user.name "github-actions[bot]"
76- git add metadata.yml CITATION.bib CITATION.cff
77- git commit -m "[Automated] Update metadata files"
78- git push
79-
80- - name : Commit changes and move tag (tag-triggered)
81- if : steps.check_changes.outputs.changes_detected == 'true' && steps.extract_version.outputs.is_tag == 'true'
82- run : |
83- # Configure git
84- git config --local user.email "github-actions[bot]@users.noreply.github.com"
85- git config --local user.name "github-actions[bot]"
86-
87- # Commit the metadata changes
88- git add metadata.yml CITATION.bib CITATION.cff
89- git commit -m "[Automated] Update metadata for version ${{ steps.extract_version.outputs.version }}"
90-
91- # Delete the old tag (locally and remotely)
92- git tag -d ${{ steps.extract_version.outputs.tag_name }}
93- git push origin :refs/tags/${{ steps.extract_version.outputs.tag_name }}
94-
95- # Create new tag at the current commit (with updated metadata)
96- git tag ${{ steps.extract_version.outputs.tag_name }}
97-
98- # Push the changes and the new tag
99- git push origin HEAD:main
100- git push origin ${{ steps.extract_version.outputs.tag_name }}
101-
102- echo "Tag ${{ steps.extract_version.outputs.tag_name }} moved to commit with updated metadata"
103-
104- - name : No changes needed
105- if : steps.check_changes.outputs.changes_detected == 'false'
106- run : |
107- if [[ "${{ steps.extract_version.outputs.is_tag }}" == "true" ]]; then
108- echo "Metadata already matches the tag version - no changes needed"
109- else
110- echo "No metadata changes detected"
111- fi
112- name : Update Metadata
113-
114- on :
115- push :
116- workflow_dispatch :
117-
118- # Prevent infinite loops when workflow commits changes
119- concurrency :
120- group : ${{ github.workflow }}-${{ github.ref }}
121- cancel-in-progress : true
122-
123- jobs :
124- update-metadata :
125- runs-on : ubuntu-latest
126- # Need write permission to push changes
127- permissions :
128- contents : write
129- steps :
130- - name : Checkout repository
131- uses : actions/checkout@v4
132- with :
133- ref : ${{ github.ref }}
134- fetch-depth : 0
135-
136- - name : Extract version from tag (if triggered by tag)
137- id : extract_version
138- run : |
139- if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
140- TAG_NAME=${GITHUB_REF#refs/tags/}
141- # Remove 'v' prefix if present (v1.0.0 -> 1.0.0)
142- VERSION=${TAG_NAME#v}
143- echo "version=$VERSION" >> $GITHUB_OUTPUT
144- echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
145- echo "is_tag=true" >> $GITHUB_OUTPUT
146- echo "Triggered by version tag: $TAG_NAME (version: $VERSION)"
147- else
148- echo "is_tag=false" >> $GITHUB_OUTPUT
149- echo "Triggered by regular push to: $GITHUB_REF"
150- fi
151-
152- - name : Set up Python
153- uses : actions/setup-python@v5
154- with :
155- python-version-file : ' .python-version'
44+ python-version-file : " .python-version"
15645 cache : pip
15746
15847 - name : Install dependencies
0 commit comments