Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ jobs:
needs: release-check
if: needs.release-check.outputs.auto-version != ''
steps:
- name: Configure
run: |
git config --global user.email "team@dandiarchive.org"
git config --global user.name "DANDI Bot"

- name: Checkout source
uses: actions/checkout@v5
with:
Expand All @@ -66,12 +71,7 @@ jobs:

- name: Get schema version
run: |
SCHEMA_VERSION="$(python -c 'from dandischema.consts import DANDI_SCHEMA_VERSION; print(DANDI_SCHEMA_VERSION)')"
if ! echo "$SCHEMA_VERSION" | grep -qP '^\d+\.\d+\.\d+$'
then printf "[ERROR] Invalid schema version: '%s'\n" "$SCHEMA_VERSION"
exit 1
fi
echo "SCHEMA_VERSION=$SCHEMA_VERSION" >> "$GITHUB_ENV"
tools/get-schema-version # it will also check if schema version is ok

- name: Checkout dandi/schema
uses: actions/checkout@v5
Expand Down Expand Up @@ -118,19 +118,6 @@ jobs:

- name: Commit schema changes and create new tag
run: |
LIBRARY_VERSION="$(git -C ../dandischema describe --tags --exact-match)"

git config --global user.email "team@dandiarchive.org"
git config --global user.name "DANDI Bot"

git add releases
if ! git diff --quiet --cached
then git commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
git push
git -C ../dandischema tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" schema-$SCHEMA_VERSION
git -C ../dandischema push --tags
else echo "No changes to commit"
fi
working-directory: schema
tools/commit-and-push-schemata ../schema

# vim:set sts=2:
27 changes: 27 additions & 0 deletions tools/commit-and-push-schemata
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -eu

tools_path=$(dirname "$0")
# Path of the `dandi-schema` repo
dandi_schema_path="${tools_path}"/..
# Path of the `schema` repo
schemata_path=${1:-.}

LIBRARY_VERSION="$(git -C "${dandi_schema_path}" describe --tags --exact-match)"
SCHEMA_VERSION="$("$tools_path"/get-schema-version)"

git -C "$schemata_path" add releases

if ! git -C "$schemata_path" diff --quiet --cached
then
# Publish/release a new schema to the `schema` repo
git -C "$schemata_path" commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
git -C "$schemata_path" push

# Tag the `dandi-schema` repo with the new schema version
git -C "$dandi_schema_path" tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" "schema-$SCHEMA_VERSION"
git -C "$dandi_schema_path" push --tags
else
echo "No changes to commit"
fi
12 changes: 12 additions & 0 deletions tools/get-schema-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python3

import re
import sys

from dandischema.consts import DANDI_SCHEMA_VERSION

if not re.match(r"[0-9]+\.[0-9]+\.[0-9]+$", DANDI_SCHEMA_VERSION):
sys.stderr.write(f"[ERROR] Invalid schema version: '{DANDI_SCHEMA_VERSION}'\n")
sys.exit(1)

print(DANDI_SCHEMA_VERSION)
Loading