diff --git a/.github/workflows/check-pr-base.yml b/.github/workflows/check-pr-base.yml new file mode 100644 index 00000000..73b71c27 --- /dev/null +++ b/.github/workflows/check-pr-base.yml @@ -0,0 +1,22 @@ +name: Git tree checks + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + merge_group: +permissions: read-all + +jobs: + check_base_ref: + name: Only release branches may merge into master + runs-on: ubuntu-latest + steps: + - id: not_based_on_master + if: | + github.event_name == 'pull_request' && + github.event.pull_request.base.ref == 'master' && + ! startsWith(github.event.pull_request.head.ref, 'release/') + run: | + echo 'Only `release/*` branches are allowed to merge into `master`.' + echo 'Maybe your PR should be merging into `staging`?' + exit 1 diff --git a/DEVELOP.md b/DEVELOP.md index 4f24f4d6..2b9ac7d9 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -2,5 +2,5 @@ ## `SpacetimeDB.ClientApi` -To regenerate this namespace, run the `tools/gen-client-api.sh` or the -`tools/gen-client-api.bat` script. +To regenerate this namespace, run the `tools~/gen-client-api.sh` or the +`tools~/gen-client-api.bat` script. diff --git a/tools~/gen-client-api.bat b/tools~/gen-client-api.bat new file mode 100644 index 00000000..9eb66c49 --- /dev/null +++ b/tools~/gen-client-api.bat @@ -0,0 +1,20 @@ +@echo off +setlocal + +if "%CL_HOME%"=="" ( + echo "Variable CL_HOME not set" + exit /b 1 +) + +cd %CL_HOME%\SpacetimeDB\crates\client-api-messages +cargo run --example get_ws_schema > %CL_HOME%/schema.json + +cd %CL_HOME%\SpacetimeDB\crates\cli +cargo run -- generate -l csharp -n SpacetimeDB.ClientApi ^ + --json-module %CL_HOME%\schema.json ^ + -o %CL_HOME%\spacetimedb-csharp-sdk\src\SpacetimeDB\ClientApi + +cd %CL_HOME%\spacetimedb-csharp-sdk\src\SpacetimeDB\ClientApi +del /q _Globals + +del %CL_HOME%\schema.json diff --git a/tools~/gen-client-api.sh b/tools~/gen-client-api.sh new file mode 100644 index 00000000..91fbe3da --- /dev/null +++ b/tools~/gen-client-api.sh @@ -0,0 +1,15 @@ +#!/bin/sh -eu +: $CL_HOME + +cd $CL_HOME/SpacetimeDB/crates/client-api-messages +cargo run --example get_ws_schema > $CL_HOME/schema.json + +cd $CL_HOME/SpacetimeDB/crates/cli +cargo run -- generate -l csharp -n SpacetimeDB.ClientApi \ + --json-module $CL_HOME/schema.json \ + -o $CL_HOME/spacetimedb-csharp-sdk/src/SpacetimeDB/ClientApi + +cd $CL_HOME/spacetimedb-csharp-sdk/src/SpacetimeDB/ClientApi +rm -rf _Globals + +rm -f $CL_HOME/schema.json