Skip to content

Create datasets releases from published tags #1

Create datasets releases from published tags

Create datasets releases from published tags #1

name: Verify generated data
on:
push:
branches:
- main
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
jobs:
verify-data:
runs-on: ubuntu-latest
steps:
- name: Check out generated formats
uses: actions/checkout@v4
- name: Verify JSON and CSV structure
run: |
python -m json.tool dataset.json >/dev/null
python - <<'PY'
import csv
import json
from pathlib import Path
records = json.loads(Path("dataset.json").read_text(encoding="utf-8"))
if not isinstance(records, list) or not records:
raise SystemExit("dataset.json must be a non-empty array")
if not all(isinstance(record, dict) for record in records):
raise SystemExit("every JSON record must be an object")
expected_fields = list(records[0])
if any(set(record) != set(expected_fields) for record in records):
raise SystemExit("JSON records have inconsistent fields")
with Path("dataset.csv").open(encoding="utf-8", newline="") as csv_file:
reader = csv.DictReader(csv_file)
rows = list(reader)
if reader.fieldnames != expected_fields:
raise SystemExit("CSV headers do not match JSON fields")
if len(rows) != len(records):
raise SystemExit("CSV and JSON record counts differ")
PY
create-release:
if: startsWith(github.ref, 'refs/tags/')
needs: verify-data
runs-on: ubuntu-latest
steps:
- name: Create datasets release for Zenodo
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${GITHUB_REF_NAME}" \
--repo "${GITHUB_REPOSITORY}" \
--verify-tag \
--title "Monomer database ${GITHUB_REF_NAME}" \
--notes "Verified JSON and CSV formats generated from the matching monomer-database-source release."