Skip to content

Commit c10d225

Browse files
authored
Merge pull request #349 from dandi/enh-release
chore: refactor release action to move schemata related code into scripts
2 parents 5cf181a + 8239313 commit c10d225

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ jobs:
4343
needs: release-check
4444
if: needs.release-check.outputs.auto-version != ''
4545
steps:
46+
- name: Configure
47+
run: |
48+
git config --global user.email "team@dandiarchive.org"
49+
git config --global user.name "DANDI Bot"
50+
4651
- name: Checkout source
4752
uses: actions/checkout@v5
4853
with:
@@ -66,12 +71,7 @@ jobs:
6671

6772
- name: Get schema version
6873
run: |
69-
SCHEMA_VERSION="$(python -c 'from dandischema.consts import DANDI_SCHEMA_VERSION; print(DANDI_SCHEMA_VERSION)')"
70-
if ! echo "$SCHEMA_VERSION" | grep -qP '^\d+\.\d+\.\d+$'
71-
then printf "[ERROR] Invalid schema version: '%s'\n" "$SCHEMA_VERSION"
72-
exit 1
73-
fi
74-
echo "SCHEMA_VERSION=$SCHEMA_VERSION" >> "$GITHUB_ENV"
74+
tools/get-schema-version # it will also check if schema version is ok
7575
7676
- name: Checkout dandi/schema
7777
uses: actions/checkout@v5
@@ -118,19 +118,6 @@ jobs:
118118

119119
- name: Commit schema changes and create new tag
120120
run: |
121-
LIBRARY_VERSION="$(git -C ../dandischema describe --tags --exact-match)"
122-
123-
git config --global user.email "team@dandiarchive.org"
124-
git config --global user.name "DANDI Bot"
125-
126-
git add releases
127-
if ! git diff --quiet --cached
128-
then git commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
129-
git push
130-
git -C ../dandischema tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" schema-$SCHEMA_VERSION
131-
git -C ../dandischema push --tags
132-
else echo "No changes to commit"
133-
fi
134-
working-directory: schema
121+
tools/commit-and-push-schemata ../schema
135122
136123
# vim:set sts=2:

tools/commit-and-push-schemata

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
tools_path=$(dirname "$0")
6+
# Path of the `dandi-schema` repo
7+
dandi_schema_path="${tools_path}"/..
8+
# Path of the `schema` repo
9+
schemata_path=${1:-.}
10+
11+
LIBRARY_VERSION="$(git -C "${dandi_schema_path}" describe --tags --exact-match)"
12+
SCHEMA_VERSION="$("$tools_path"/get-schema-version)"
13+
14+
git -C "$schemata_path" add releases
15+
16+
if ! git -C "$schemata_path" diff --quiet --cached
17+
then
18+
# Publish/release a new schema to the `schema` repo
19+
git -C "$schemata_path" commit -m "Publish model schema v$SCHEMA_VERSION as of dandischema v$LIBRARY_VERSION"
20+
git -C "$schemata_path" push
21+
22+
# Tag the `dandi-schema` repo with the new schema version
23+
git -C "$dandi_schema_path" tag -m "Schema v$SCHEMA_VERSION, released in dandischema v$LIBRARY_VERSION" "schema-$SCHEMA_VERSION"
24+
git -C "$dandi_schema_path" push --tags
25+
else
26+
echo "No changes to commit"
27+
fi

tools/get-schema-version

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python3
2+
3+
import re
4+
import sys
5+
6+
from dandischema.consts import DANDI_SCHEMA_VERSION
7+
8+
if not re.match(r"[0-9]+\.[0-9]+\.[0-9]+$", DANDI_SCHEMA_VERSION):
9+
sys.stderr.write(f"[ERROR] Invalid schema version: '{DANDI_SCHEMA_VERSION}'\n")
10+
sys.exit(1)
11+
12+
print(DANDI_SCHEMA_VERSION)

0 commit comments

Comments
 (0)