diff --git a/.github/dependabot.yml b/.github/dependabot.yml index efb5eb5761..09fccd1fbc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -146,6 +146,7 @@ updates: - package-ecosystem: docker-compose directories: # - /scripts # Maybe + - /scripts/api - /tests/e2e schedule: interval: daily diff --git a/Makefile b/Makefile index e809f00412..dc39cbd5d5 100644 --- a/Makefile +++ b/Makefile @@ -149,14 +149,13 @@ gen-changelog: ## (Release) generate the changelog based from the commits since npx prettier --write changelog.md gen-diff: ## (Release) generate the changelog diff between the current schema and the last tag - git show $(shell git describe --tags $(shell git rev-list --tags --max-count=1)):schema.yml > old_schema.yml - docker run \ - --rm -v ${PWD}:/local \ - --user ${UID}:${GID} \ - docker.io/openapitools/openapi-diff:2.1.0-beta.8 \ - --markdown /local/diff.md \ - /local/old_schema.yml /local/schema.yml - rm old_schema.yml + git show $(shell git describe --tags $(shell git rev-list --tags --max-count=1)):schema.yml > schema-old.yml + docker compose -f scripts/api/docker-compose.yml run --rm --user "${UID}:${GID}" diff \ + --markdown \ + /local/diff.md \ + /local/schema-old.yml \ + /local/schema.yml + rm schema-old.yml sed -i 's/{/{/g' diff.md sed -i 's/}/}/g' diff.md npx prettier --write diff.md @@ -165,28 +164,21 @@ gen-clean-ts: ## Remove generated API client for TypeScript rm -rf ${PWD}/${GEN_API_TS}/ rm -rf ${PWD}/web/node_modules/@goauthentik/api/ -gen-clean-go: ## Remove generated API client for Go - mkdir -p ${PWD}/${GEN_API_GO} -ifneq ($(wildcard ${PWD}/${GEN_API_GO}/.*),) - make -C ${PWD}/${GEN_API_GO} clean -else - rm -rf ${PWD}/${GEN_API_GO} -endif - gen-clean-py: ## Remove generated API client for Python - rm -rf ${PWD}/${GEN_API_PY}/ + rm -rf ${PWD}/${GEN_API_PY} + +gen-clean-go: ## Remove generated API client for Go + rm -rf ${PWD}/${GEN_API_GO} gen-clean: gen-clean-ts gen-clean-go gen-clean-py ## Remove generated API clients gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescript into the authentik UI Application - docker run \ - --rm -v ${PWD}:/local \ - --user ${UID}:${GID} \ - docker.io/openapitools/openapi-generator-cli:v7.15.0 generate \ + docker compose -f scripts/api/docker-compose.yml run --rm --user "${UID}:${GID}" gen \ + generate \ -i /local/schema.yml \ -g typescript-fetch \ -o /local/${GEN_API_TS} \ - -c /local/scripts/api-ts-config.yaml \ + -c /local/scripts/api/ts-config.yaml \ --additional-properties=npmVersion=${NPM_VERSION} \ --git-repo-id authentik \ --git-user-id goauthentik @@ -196,17 +188,14 @@ gen-client-ts: gen-clean-ts ## Build and install the authentik API for Typescri cd ${PWD}/web && npm link @goauthentik/api gen-client-py: gen-clean-py ## Build and install the authentik API for Python - docker run \ - --rm -v ${PWD}:/local \ - --user ${UID}:${GID} \ - docker.io/openapitools/openapi-generator-cli:v7.15.0 generate \ - -i /local/schema.yml \ - -g python \ - -o /local/${GEN_API_PY} \ - -c /local/scripts/api-py-config.yaml \ - --additional-properties=packageVersion=${NPM_VERSION} \ - --git-repo-id authentik \ - --git-user-id goauthentik + mkdir -p ${PWD}/${GEN_API_PY} +ifeq ($(wildcard ${PWD}/${GEN_API_PY}/.*),) + git clone --depth 1 https://github.com/goauthentik/client-python.git ${PWD}/${GEN_API_PY} +else + cd ${PWD}/${GEN_API_PY} && git pull +endif + cp ${PWD}/schema.yml ${PWD}/${GEN_API_PY} + make -C ${PWD}/${GEN_API_PY} build version=${NPM_VERSION} gen-client-go: gen-clean-go ## Build and install the authentik API for Golang mkdir -p ${PWD}/${GEN_API_GO} diff --git a/scripts/api-py-config.yaml b/scripts/api-py-config.yaml deleted file mode 100644 index 95dcf5597b..0000000000 --- a/scripts/api-py-config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -additionalProperties: - packageName: authentik_client - projectName: authentik-client - infoName: authentik Team diff --git a/scripts/api/docker-compose.yml b/scripts/api/docker-compose.yml new file mode 100644 index 0000000000..10ac3b08df --- /dev/null +++ b/scripts/api/docker-compose.yml @@ -0,0 +1,15 @@ +--- +services: + diff: + image: docker.io/openapitools/openapi-diff:2.1.3 + restart: never + network_mode: none + volumes: + - ../../:/local + + gen: + image: docker.io/openapitools/openapi-generator-cli:v7.16.0 + restart: never + network_mode: none + volumes: + - ../../:/local diff --git a/scripts/api-ts-config.yaml b/scripts/api/ts-config.yaml similarity index 85% rename from scripts/api-ts-config.yaml rename to scripts/api/ts-config.yaml index 86577b10b7..547acb980e 100644 --- a/scripts/api-ts-config.yaml +++ b/scripts/api/ts-config.yaml @@ -1,4 +1,4 @@ -templateDir: /local/scripts/api-ts-templates/ +templateDir: /local/scripts/api/ts-templates/ additionalProperties: typescriptThreePlus: true supportsES6: true diff --git a/scripts/api-ts-templates/README.mustache b/scripts/api/ts-templates/README.mustache similarity index 100% rename from scripts/api-ts-templates/README.mustache rename to scripts/api/ts-templates/README.mustache diff --git a/scripts/api-ts-templates/tsconfig.esm.mustache b/scripts/api/ts-templates/tsconfig.esm.mustache similarity index 100% rename from scripts/api-ts-templates/tsconfig.esm.mustache rename to scripts/api/ts-templates/tsconfig.esm.mustache diff --git a/scripts/api-ts-templates/tsconfig.mustache b/scripts/api/ts-templates/tsconfig.mustache similarity index 100% rename from scripts/api-ts-templates/tsconfig.mustache rename to scripts/api/ts-templates/tsconfig.mustache