Skip to content

Commit b54b525

Browse files
committed
No loop, just work on src/schemas/validation
1 parent d6d0fe7 commit b54b525

File tree

1 file changed

+38
-41
lines changed

1 file changed

+38
-41
lines changed

scripts/schema-publish.sh

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,48 @@
44

55
# Run this script from the root of the repo. It is designed to be run by a GitHub workflow.
66

7-
for schemaDir in schemas/v3* ; do
8-
vVersion=$(basename "$schemaDir")
9-
version=${vVersion:1}
10-
echo $version
11-
12-
# list of schemas to process, dependent schemas come first
13-
schemas=(meta.yaml dialect.yaml schema.yaml schema-base.yaml)
14-
15-
# find the newest commit date for each schema
16-
maxDate=""
17-
declare -A datesHash
18-
for schema in "${schemas[@]}"; do
19-
if [ -f "$schemaDir/$schema" ]; then
20-
newestCommitDate=$(git log -1 --format="%ad" --date=short "$schemaDir/$schema")
21-
22-
# the newest date across a schema and all its dependencies is its date stamp
23-
if [ "$newestCommitDate" \> "$maxDate" ]; then
24-
maxDate=$newestCommitDate
25-
fi
26-
datesHash["$schema"]=$maxDate
27-
echo $schema changed at $newestCommitDate
7+
schemaDir="src/schemas/validation"
8+
branch=$(git branch --show-current)
9+
version=${branch:1:3}
10+
echo $version
11+
12+
# list of schemas to process, dependent schemas come first
13+
schemas=(meta.yaml dialect.yaml schema.yaml schema-base.yaml)
14+
15+
# find the newest commit date for each schema
16+
maxDate=""
17+
declare -A datesHash
18+
for schema in "${schemas[@]}"; do
19+
if [ -f "$schemaDir/$schema" ]; then
20+
newestCommitDate=$(git log -1 --format="%ad" --date=short "$schemaDir/$schema")
21+
22+
# the newest date across a schema and all its dependencies is its date stamp
23+
if [ "$newestCommitDate" \> "$maxDate" ]; then
24+
maxDate=$newestCommitDate
2825
fi
29-
done
30-
31-
# construct sed command
32-
sedCmd=()
33-
for schema in "${!datesHash[@]}"; do
34-
base=$(basename "$schema" .yaml)
35-
sedCmd+=("-e s/$base\/WORK-IN-PROGRESS/$base\/${datesHash[$schema]}/g")
36-
done
26+
datesHash["$schema"]=$maxDate
27+
echo $schema changed at $newestCommitDate
28+
fi
29+
done
3730

38-
# create the date-stamped schemas
39-
for schema in "${!datesHash[@]}"; do
40-
base=$(basename "$schema" .yaml)
41-
target=deploy/oas/$version/$base/${datesHash[$schema]}
31+
# construct sed command
32+
sedCmd=()
33+
for schema in "${!datesHash[@]}"; do
34+
base=$(basename "$schema" .yaml)
35+
sedCmd+=("-e s/$base\/WORK-IN-PROGRESS/$base\/${datesHash[$schema]}/g")
36+
done
4237

43-
mkdir -p "deploy/oas/$version/$base"
38+
# create the date-stamped schemas
39+
for schema in "${!datesHash[@]}"; do
40+
base=$(basename "$schema" .yaml)
41+
target=deploy/oas/$version/$base/${datesHash[$schema]}
4442

45-
sed ${sedCmd[@]} $schemaDir/$schema > $target.yaml
46-
node scripts/yaml2json/yaml2json.js $target.yaml
47-
rm $target.yaml
48-
mv $target.json $target
43+
mkdir -p "deploy/oas/$version/$base"
4944

50-
mv deploy/oas/$version/$base/*.md $target.md
51-
done
45+
sed ${sedCmd[@]} $schemaDir/$schema > $target.yaml
46+
node scripts/yaml2json/yaml2json.js $target.yaml
47+
rm $target.yaml
48+
mv $target.json $target
5249

53-
echo ""
50+
mv deploy/oas/$version/$base/*.md $target.md
5451
done

0 commit comments

Comments
 (0)