Skip to content

Commit e254d1d

Browse files
authored
Merge pull request #8 from datacite/release-import-automation
Add modular DataCite release import workflows
2 parents b29eeb6 + c81fa5c commit e254d1d

23 files changed

+3817
-602
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Apply DataCite Release Plan
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
plan_path:
7+
description: 'Path to the approved plan file, for example reports/release-import-plan-4.7.json'
8+
required: true
9+
type: string
10+
set_current:
11+
description: 'Update datacite-current pointers while generating outputs.'
12+
required: false
13+
default: true
14+
type: boolean
15+
commit_generated_files:
16+
description: 'Commit generated source and output files back to the selected branch.'
17+
required: false
18+
default: true
19+
type: boolean
20+
apply_controlled_lists:
21+
description: 'Enable the controlled-list module.'
22+
required: false
23+
default: true
24+
type: boolean
25+
apply_simple_properties:
26+
description: 'Enable the simple-property module.'
27+
required: false
28+
default: true
29+
type: boolean
30+
apply_property_groups:
31+
description: 'Enable the property-group module.'
32+
required: false
33+
default: true
34+
type: boolean
35+
apply_complex_structures:
36+
description: 'Enable the complex-structure module.'
37+
required: false
38+
default: true
39+
type: boolean
40+
apply_renames:
41+
description: 'Enable the rename module.'
42+
required: false
43+
default: false
44+
type: boolean
45+
apply_removals:
46+
description: 'Enable the removal module.'
47+
required: false
48+
default: false
49+
type: boolean
50+
51+
permissions:
52+
contents: write
53+
54+
jobs:
55+
apply-release-plan:
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@v6
61+
with:
62+
fetch-depth: 0
63+
64+
- name: Setup Node
65+
uses: actions/setup-node@v6
66+
with:
67+
node-version: '20'
68+
69+
- name: Apply approved release plan
70+
run: |
71+
modules=()
72+
73+
if [ "${{ inputs.apply_controlled_lists }}" = "true" ]; then
74+
modules+=(controlled-list)
75+
fi
76+
if [ "${{ inputs.apply_simple_properties }}" = "true" ]; then
77+
modules+=(simple-property)
78+
fi
79+
if [ "${{ inputs.apply_property_groups }}" = "true" ]; then
80+
modules+=(property-group)
81+
fi
82+
if [ "${{ inputs.apply_complex_structures }}" = "true" ]; then
83+
modules+=(complex-structure)
84+
fi
85+
if [ "${{ inputs.apply_renames }}" = "true" ]; then
86+
modules+=(rename)
87+
fi
88+
if [ "${{ inputs.apply_removals }}" = "true" ]; then
89+
modules+=(removal)
90+
fi
91+
92+
module_csv=$(IFS=, ; echo "${modules[*]}")
93+
94+
args=(--plan "${{ inputs.plan_path }}")
95+
if [ -n "$module_csv" ]; then
96+
args+=(--modules "$module_csv")
97+
fi
98+
if [ "${{ inputs.set_current }}" = "true" ]; then
99+
args+=(--set-current)
100+
fi
101+
102+
node scripts/apply-datacite-release-plan.js "${args[@]}"
103+
104+
- name: Resolve apply artifact paths
105+
run: |
106+
RESOLVED_VERSION=$(basename "${{ inputs.plan_path }}" .json | sed 's/^release-import-plan-//')
107+
REPORT_PATH="reports/release-apply-${RESOLVED_VERSION}.md"
108+
echo "RESOLVED_VERSION=$RESOLVED_VERSION" >> "$GITHUB_ENV"
109+
echo "REPORT_PATH=$REPORT_PATH" >> "$GITHUB_ENV"
110+
111+
- name: Add apply report to workflow summary
112+
run: |
113+
cat "$REPORT_PATH" >> "$GITHUB_STEP_SUMMARY"
114+
115+
- name: Commit generated files
116+
if: ${{ inputs.commit_generated_files }}
117+
env:
118+
VERSION: ${{ env.RESOLVED_VERSION }}
119+
run: |
120+
git config user.name "github-actions[bot]"
121+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
122+
git add \
123+
reports/release-import-plan-*.md \
124+
reports/release-apply-*.md \
125+
manifest/release-matrix-*.json \
126+
manifest/datacite-*.json \
127+
dist/datacite-*.jsonld \
128+
dist/datacite-*.ttl \
129+
dist/datacite-*.rdf \
130+
context/fullcontext.jsonld \
131+
property/*.jsonld \
132+
class/*.jsonld \
133+
vocab/*/*.jsonld \
134+
class/index.html \
135+
context/index.html \
136+
dist/index.html \
137+
manifest/index.html \
138+
property/index.html \
139+
vocab/index.html \
140+
index.html
141+
142+
if git diff --cached --quiet; then
143+
echo "No generated changes to commit."
144+
exit 0
145+
fi
146+
147+
git commit -m "chore: apply DataCite release plan ${VERSION}"
148+
git push origin HEAD:${GITHUB_REF_NAME}
149+
150+
- name: Upload apply artifacts
151+
uses: actions/upload-artifact@v7
152+
with:
153+
name: datacite-release-apply-${{ env.RESOLVED_VERSION }}
154+
path: |
155+
${{ inputs.plan_path }}
156+
reports/release-import-plan-*.md
157+
${{ env.REPORT_PATH }}
158+
manifest/release-matrix-*.json
159+
manifest/datacite-*.json
160+
dist/datacite-*.jsonld
161+
dist/datacite-*.ttl
162+
dist/datacite-*.rdf
163+
context/fullcontext.jsonld
164+
property/*.jsonld
165+
class/*.jsonld
166+
vocab/*/*.jsonld
167+
class/index.html
168+
context/index.html
169+
dist/index.html
170+
manifest/index.html
171+
property/index.html
172+
vocab/index.html
173+
index.html
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Detect DataCite Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Optional target DataCite schema version. Leave blank to detect the next official 4.x release from schema.datacite.org/versions.html.'
8+
required: false
9+
type: string
10+
release_date:
11+
description: 'Optional official release date (YYYY-MM-DD). Leave blank to use the date published on schema.datacite.org/versions.html.'
12+
required: false
13+
type: string
14+
commit_plan_files:
15+
description: 'Commit the generated plan files back to the selected branch so they can be reviewed and edited on GitHub.'
16+
required: false
17+
default: true
18+
type: boolean
19+
20+
permissions:
21+
contents: write
22+
23+
jobs:
24+
detect-release:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v6
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup Node
34+
uses: actions/setup-node@v6
35+
with:
36+
node-version: '20'
37+
38+
- name: Detect release plan
39+
run: |
40+
args=()
41+
42+
if [ -n "${{ inputs.version }}" ]; then
43+
args+=(--version "${{ inputs.version }}")
44+
fi
45+
46+
if [ -n "${{ inputs.release_date }}" ]; then
47+
args+=(--release-date "${{ inputs.release_date }}")
48+
fi
49+
50+
node scripts/detect-datacite-release.js "${args[@]}"
51+
52+
- name: Resolve artifact paths
53+
run: |
54+
PLAN_PATH=$(ls reports/release-import-plan-*.json | head -n 1)
55+
REPORT_PATH=$(ls reports/release-import-plan-*.md | head -n 1)
56+
RESOLVED_VERSION=$(basename "$PLAN_PATH" .json | sed 's/^release-import-plan-//')
57+
echo "PLAN_PATH=$PLAN_PATH" >> "$GITHUB_ENV"
58+
echo "REPORT_PATH=$REPORT_PATH" >> "$GITHUB_ENV"
59+
echo "RESOLVED_VERSION=$RESOLVED_VERSION" >> "$GITHUB_ENV"
60+
61+
- name: Add detection report to workflow summary
62+
run: |
63+
cat "$REPORT_PATH" >> "$GITHUB_STEP_SUMMARY"
64+
65+
- name: Commit plan files
66+
if: ${{ inputs.commit_plan_files }}
67+
env:
68+
VERSION: ${{ env.RESOLVED_VERSION }}
69+
run: |
70+
git config user.name "github-actions[bot]"
71+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
72+
git add "$PLAN_PATH" "$REPORT_PATH"
73+
74+
if git diff --cached --quiet; then
75+
echo "No plan changes to commit."
76+
exit 0
77+
fi
78+
79+
git commit -m "chore: detect DataCite release plan ${VERSION}"
80+
git push origin HEAD:${GITHUB_REF_NAME}
81+
82+
- name: Upload detection artifacts
83+
uses: actions/upload-artifact@v7
84+
with:
85+
name: datacite-release-plan-${{ env.RESOLVED_VERSION }}
86+
path: |
87+
${{ env.PLAN_PATH }}
88+
${{ env.REPORT_PATH }}

0 commit comments

Comments
 (0)