44 push :
55 branches :
66 - " master"
7+ - " maint/*"
78
89concurrency :
910 group : ${{ github.workflow }}-${{ github.ref }}
@@ -34,13 +35,27 @@ jobs:
3435 - uses : actions/setup-python@v5
3536 with :
3637 python-version : 3
38+ - run : env
39+ - run : git status
40+ - name : Determine master/maintenance branch
41+ id : branch
42+ run : |
43+ if [[ "$GITHUB_REF_NAME" = "master" ]]; then
44+ echo "branch=jsr-dist" | tee -a $GITHUB_OUTPUT
45+ echo "mode=dev" | tee -a $GITHUB_OUTPUT
46+ else
47+ echo "branch=jsr-maint" | tee -a $GITHUB_OUTPUT
48+ echo "mode=maint" | tee -a $GITHUB_OUTPUT
49+ fi
3750 - name : Install bidsschematools
3851 run : |
3952 pip install --upgrade tools/schemacode
4053 git clean -fxd tools/schemacode
41- - name : Checkout jsr-dist
54+ - name : Checkout ${{ steps.branch.outputs.branch }}
4255 run : |
43- git checkout -t origin/jsr-dist
56+ git checkout -t origin/$JSR_BRANCH
57+ env :
58+ JSR_BRANCH : ${{ steps.branch.outputs.branch }}
4459 - name : Regenerate schema
4560 run : bst export > schema.json
4661 - name : Regenerate context types
@@ -54,36 +69,46 @@ jobs:
5469 bst export-metaschema > /tmp/schema.json
5570 npx --package=json-schema-to-typescript json2ts --unknownAny /tmp/schema.json > metaschema.ts
5671 - name : Determine next version
72+ id : version
5773 run : |
5874 BASE=$( jq -r .schema_version schema.json )
59- if [[ "$BASE" =~ ^[0-9]*.[0-9]*.[0-9]*$ ]]; then
75+ if [[ "$BASE" =~ ^[0-9]*\ .[0-9]*\ .[0-9]*$ ]]; then
6076 # Release, so unconditionally update version
6177 VERSION=$BASE
6278 jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
63- else
79+ echo release=true | tee -a $GITHUB_OUTPUT
80+ elif [[ "$BASE" =~ ^[0-9]*\.[0-9]*\.[0-9]*\.post[0-9]*$ ]]; then
81+ # Post-release, so replace .post with + for JSR semver
82+ VERSION=${BASE/.post/+}
83+ jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
84+ echo release=true | tee -a $GITHUB_OUTPUT
85+ elif [[ "$GITHUB_REF_NAME" = "master" ]]; then
6486 DENOVER=$( jq -r .version jsr.json )
6587 # Get the reference of the latest commit to touch the schema directory
66- HASH=$( git log -n 1 --pretty=%h $REF -- src/schema )
88+ HASH=$( git log -n 1 --pretty=%h $GITHUB_REF -- src/schema )
6789 if [[ $DENOVER =~ ^"$BASE".[0-9] ]]; then
6890 PREFIX=${DENOVER%+*}
6991 let SERIAL=1+${PREFIX#$BASE.}
7092 else
7193 SERIAL=1
7294 fi
7395 VERSION="$BASE.$SERIAL+$HASH"
96+ echo release=true | tee -a $GITHUB_OUTPUT
97+ else
98+ echo release=false | tee -a $GITHUB_OUTPUT
7499 fi
75100 echo VERSION=$VERSION | tee -a $GITHUB_ENV
76- env :
77- REF : ${{ github.ref }}
78- - name : Check for changes, set version and commit
101+ echo version=$VERSION | tee -a $GITHUB_OUTPUT
102+ - name : Bump version ( ${{ steps.version.outputs.version }}) if changed
103+ if : steps. version.outputs.release == 'true'
79104 run : |
80105 if ! git diff -s --exit-code; then
81106 jq ".version = \"$VERSION\"" jsr.json > tmp.json && mv tmp.json jsr.json
82107 git add jsr.json schema.json context.ts metaschema.ts
83- git commit -m "Update schema JSR distribution"
108+ git commit -m "Update schema JSR distribution ($VERSION) "
84109 git push
85110 fi
86111 - name : Publish to JSR
87- if : success()
112+ if : success() && steps.version.outputs.release == 'true'
88113 run : |
89114 npx jsr publish
0 commit comments