Skip to content

Commit ed2f57b

Browse files
committed
feat: Update metadata scripts and actions
1 parent cdade2f commit ed2f57b

19 files changed

+3673
-579
lines changed

.github/workflows/deploy-book-python-only.yml

Lines changed: 53 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,44 +18,56 @@ jobs:
1818
id-token: write
1919
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2020
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
23-
24-
# Python
25-
- name: Set up Python 3.11
26-
uses: actions/setup-python@v5
27-
with:
28-
python-version: 3.11
29-
cache: pip
30-
31-
- name: Install Python dependencies
32-
run: |
33-
pip install -r requirements.txt
34-
35-
36-
# check all kernels
37-
- name: Log all available kernels
38-
run: |
39-
jupyter kernelspec list
40-
41-
# only caches if set up in _config.yml with:
42-
# execute:
43-
# execute_notebooks: cache
44-
- name: Cache executed notebooks
45-
uses: actions/cache@v3
46-
with:
47-
path: _build/.jupyter_cache
48-
key: jupyter-book-cache-${{ hashFiles('requirements.txt') }}
49-
50-
- name: Build the book
51-
run: |
52-
jupyter-book build .
53-
54-
- name: Upload book artifact
55-
uses: actions/upload-pages-artifact@v3
56-
with:
57-
path: "_build/html"
58-
59-
- name: Deploy to GitHub Pages
60-
id: deployment
61-
uses: actions/deploy-pages@v4
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
# Set up Python with pip caching
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version-file: ".python-version"
29+
cache: pip
30+
31+
# Cache executed notebooks
32+
# only caches if set up in _config.yml with:
33+
# execute:
34+
# execute_notebooks: cache
35+
- name: Cache executed notebooks
36+
uses: actions/cache@v3
37+
with:
38+
path: _build/.jupyter_cache
39+
key: jupyter-book-cache-${{ hashFiles('requirements.txt') }}
40+
41+
# Install Python dependencies
42+
- name: Install Python dependencies
43+
run: |
44+
pip install -r requirements.txt
45+
46+
# Check all kernels
47+
- name: Log all available kernels
48+
run: |
49+
jupyter kernelspec list
50+
51+
- name: Build the book
52+
run: |
53+
jupyter-book build .
54+
55+
- name: Inject all metadata into HTML
56+
run: |
57+
python -m quadriga.metadata.inject_all_metadata
58+
echo "Injected all metadata (OpenGraph, JSON-LD, and RDF links) into HTML head"
59+
60+
- name: Copy metadata files to build directory
61+
run: |
62+
cp metadata.jsonld _build/html/metadata.jsonld
63+
cp metadata.rdf _build/html/metadata.rdf
64+
echo "Copied metadata files to _build/html for discovery"
65+
66+
- name: Upload book artifact
67+
uses: actions/upload-pages-artifact@v3
68+
with:
69+
path: "_build/html"
70+
71+
- name: Deploy to GitHub Pages
72+
id: deployment
73+
uses: actions/deploy-pages@v4

.github/workflows/update-metadata.yml

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,94 @@ jobs:
2020
uses: actions/checkout@v4
2121
with:
2222
ref: ${{ github.ref }}
23+
fetch-depth: 0
24+
25+
- name: Extract version from tag (if triggered by tag)
26+
id: extract_version
27+
run: |
28+
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
29+
TAG_NAME=${GITHUB_REF#refs/tags/}
30+
# Remove 'v' prefix if present (v1.0.0 -> 1.0.0)
31+
VERSION=${TAG_NAME#v}
32+
echo "version=$VERSION" >> $GITHUB_OUTPUT
33+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
34+
echo "is_tag=true" >> $GITHUB_OUTPUT
35+
echo "Triggered by version tag: $TAG_NAME (version: $VERSION)"
36+
else
37+
echo "is_tag=false" >> $GITHUB_OUTPUT
38+
echo "Triggered by regular push to: $GITHUB_REF"
39+
fi
2340
2441
- name: Set up Python
2542
uses: actions/setup-python@v5
2643
with:
27-
python-version: '3.11'
44+
python-version-file: ".python-version"
2845
cache: pip
29-
46+
3047
- name: Install dependencies
3148
run: |
3249
python -m pip install --upgrade pip
33-
pip install pyyaml
34-
50+
pip install pyyaml rdflib
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+
3559
- name: Update metadata files
60+
env:
61+
PYTHONHASHSEED: 0
3662
run: python -m quadriga.metadata.run_all
37-
63+
3864
- name: Check if files changed
3965
id: check_changes
4066
run: |
41-
if git diff --quiet metadata.yml && git diff --quiet CITATION.bib && git diff --quiet CITATION.cff; then
67+
if git diff --quiet metadata.yml && git diff --quiet CITATION.bib && git diff --quiet CITATION.cff && git diff --quiet .zenodo.json && git diff --quiet metadata.jsonld && git diff --quiet metadata.rdf; then
4268
echo "changes_detected=false" >> $GITHUB_OUTPUT
4369
else
4470
echo "changes_detected=true" >> $GITHUB_OUTPUT
4571
fi
46-
47-
- name: Commit changes if necessary
48-
if: steps.check_changes.outputs.changes_detected == 'true'
72+
73+
- name: Commit changes (regular push)
74+
if: steps.check_changes.outputs.changes_detected == 'true' && steps.extract_version.outputs.is_tag == 'false'
4975
run: |
5076
git config --local user.email "github-actions[bot]@users.noreply.github.com"
5177
git config --local user.name "github-actions[bot]"
52-
git add metadata.yml CITATION.bib CITATION.cff
78+
git add metadata.yml CITATION.bib CITATION.cff .zenodo.json metadata.jsonld metadata.rdf
5379
git commit -m "[Automated] Update metadata files"
54-
git push
80+
git push
81+
82+
- name: Commit changes and move tag (tag-triggered)
83+
if: steps.check_changes.outputs.changes_detected == 'true' && steps.extract_version.outputs.is_tag == 'true'
84+
run: |
85+
# Configure git
86+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
87+
git config --local user.name "github-actions[bot]"
88+
89+
# Commit the metadata changes
90+
git add metadata.yml CITATION.bib CITATION.cff .zenodo.json metadata.jsonld metadata.rdf
91+
git commit -m "[Automated] Update metadata for version ${{ steps.extract_version.outputs.version }}"
92+
93+
# Delete the old tag (locally and remotely)
94+
git tag -d ${{ steps.extract_version.outputs.tag_name }}
95+
git push origin :refs/tags/${{ steps.extract_version.outputs.tag_name }}
96+
97+
# Create new tag at the current commit (with updated metadata)
98+
git tag ${{ steps.extract_version.outputs.tag_name }}
99+
100+
# Push the changes and the new tag
101+
git push origin HEAD:main
102+
git push origin ${{ steps.extract_version.outputs.tag_name }}
103+
104+
echo "Tag ${{ steps.extract_version.outputs.tag_name }} moved to commit with updated metadata"
105+
106+
- name: No changes needed
107+
if: steps.check_changes.outputs.changes_detected == 'false'
108+
run: |
109+
if [[ "${{ steps.extract_version.outputs.is_tag }}" == "true" ]]; then
110+
echo "Metadata already matches the tag version - no changes needed"
111+
else
112+
echo "No metadata changes detected"
113+
fi

.zenodo.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"upload_type": "lesson",
3+
"title": "Anreicherung und Publikation von Annotationsdatensets auf Repositorien",
4+
"creators": [
5+
{
6+
"name": "Demir, Derya",
7+
"affiliation": "Freie Universität Berlin"
8+
},
9+
{
10+
"name": "Grotkopp, Matthias",
11+
"affiliation": "Freie Universität Berlin",
12+
"orcid": "0000-0002-0954-3111"
13+
}
14+
],
15+
"description": "Dieses interaktive Lehrbuch ist das Outcome der 1. Fallstudie des Datentyps Bewegtes Bild des Projekts [QUADRIGA](https://quadriga-dk.de).",
16+
"publication_date": "2025-01-01",
17+
"license": "CC-BY-SA-4.0",
18+
"language": "deu",
19+
"related_identifiers": [
20+
{
21+
"identifier": "TODO",
22+
"relation": "isSupplementedBy",
23+
"scheme": "url"
24+
}
25+
],
26+
"communities": [
27+
{
28+
"identifier": "quadriga"
29+
}
30+
]
31+
}

dev-requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
pyyaml
1+
pyyaml
2+
mypy
3+
ruff
4+
types-PyYAML
5+
rdflib

metadata.jsonld

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"@context": {
3+
"schema": "http://schema.org/",
4+
"dc": "http://purl.org/dc/elements/1.1/",
5+
"dcterms": "http://purl.org/dc/terms/",
6+
"lrmi": "http://purl.org/dcx/lrmi-terms/",
7+
"skos": "http://www.w3.org/2004/02/skos/core#",
8+
"@vocab": "http://schema.org/"
9+
},
10+
"@type": [
11+
"Book",
12+
"LearningResource"
13+
],
14+
"name": "Anreicherung und Publikation von Annotationsdatensets auf Repositorien",
15+
"description": {
16+
"introduction": "TODO",
17+
"table-of-contents": "- Präambel\n- Forschungsdaten & Datenmanagement in der Filmwissenschaft\n- Epilog"
18+
},
19+
"identifier": {
20+
"@type": "PropertyValue",
21+
"propertyID": "DOI",
22+
"value": "TODO",
23+
"url": "TODO"
24+
},
25+
"schemaVersion": "1.1-beta2",
26+
"url": "TODO",
27+
"workExample": {
28+
"@type": "SoftwareSourceCode",
29+
"name": "Source Code Repository",
30+
"codeRepository": "TODO"
31+
},
32+
"author": [
33+
{
34+
"@type": "Person",
35+
"givenName": "Derya",
36+
"familyName": "Demir",
37+
"name": "Derya Demir",
38+
"affiliation": {
39+
"@type": "Organization",
40+
"name": "Freie Universität Berlin"
41+
}
42+
},
43+
{
44+
"@type": "Person",
45+
"givenName": "Matthias",
46+
"familyName": "Grotkopp",
47+
"name": "Matthias Grotkopp",
48+
"identifier": {
49+
"@type": "PropertyValue",
50+
"propertyID": "ORCID",
51+
"value": "0000-0002-0954-3111",
52+
"url": "https://orcid.org/0000-0002-0954-3111"
53+
},
54+
"affiliation": {
55+
"@type": "Organization",
56+
"name": "Freie Universität Berlin"
57+
}
58+
}
59+
],
60+
"about": [
61+
{
62+
"@type": "Thing",
63+
"name": "übergreifend"
64+
}
65+
],
66+
"audience": [
67+
{
68+
"@type": "Audience",
69+
"audienceType": "Forschende (PostDoc)"
70+
},
71+
{
72+
"@type": "Audience",
73+
"audienceType": "Forschende (Projektleitung)"
74+
},
75+
{
76+
"@type": "Audience",
77+
"audienceType": "Promovierende"
78+
}
79+
],
80+
"license": [
81+
{
82+
"@type": "CreativeWork",
83+
"name": "Source Code",
84+
"license": "https://opensource.org/licenses/AGPL-3.0"
85+
},
86+
{
87+
"@type": "CreativeWork",
88+
"name": "Content",
89+
"license": "https://creativecommons.org/licenses/by-sa/4.0/"
90+
}
91+
],
92+
"hasPart": [
93+
{
94+
"@type": "LearningResource",
95+
"name": "TODO",
96+
"description": "TODO",
97+
"teaches": "TODO",
98+
"educationalAlignment": [
99+
{
100+
"@type": "AlignmentObject",
101+
"targetName": "TODO",
102+
"educationalFramework": "QUADRIGA Competency Framework",
103+
"targetDescription": "Competency: 1 Basiskompetenz | Bloom's: 2 Verstehen | Data Flow: Grundlagen"
104+
}
105+
]
106+
}
107+
],
108+
"funding": "Die vorliegenden Open Educational Resources wurden durch das Datenkompetenzzentrum QUADRIGA erstellt.\nFörderkennzeichen: 16DKZ1034"
109+
}

0 commit comments

Comments
 (0)