diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index aabd75cd..462c0e5d 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -1,9 +1,11 @@ name: Build and Deploy Documentation on: + push: + branches: + - main release: - types: [released] - workflow_dispatch: + types: [published] permissions: contents: write @@ -13,17 +15,15 @@ permissions: jobs: build: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Install uv uses: astral-sh/setup-uv@v5 with: - enable-cache: true + enable-cache: true - name: Set up Python run: uv python install @@ -31,7 +31,18 @@ jobs: - name: Install the project run: uv sync --all-extras --dev - - run: uv run mkdocs gh-deploy --force + - name: Configure Git + run: | + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Build Docs Website + run: | + if [ "${{ github.event_name }}" = "release" ]; then + uv run mike deploy --push --update-aliases ${{ github.event.release.tag_name }} latest + else + uv run mike deploy --push main + fi deploy: needs: build @@ -44,12 +55,16 @@ jobs: uses: actions/checkout@v4 with: ref: gh-pages + - name: Setup Pages uses: actions/configure-pages@v5 + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: '.' + - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + diff --git a/crates/pgt_workspace/src/configuration.rs b/crates/pgt_workspace/src/configuration.rs index 1baebcc7..87e77b0c 100644 --- a/crates/pgt_workspace/src/configuration.rs +++ b/crates/pgt_workspace/src/configuration.rs @@ -186,9 +186,9 @@ pub fn create_config( configuration.schema = node_schema_path.to_str().map(String::from); } else if VERSION == "0.0.0" { // VERSION is 0.0.0 if it has not been explicitly set (e.g local dev, as fallback) - configuration.schema = Some("https://pgtools.dev/schemas/latest/schema.json".to_string()); + configuration.schema = Some("https://pgtools.dev/latest/schema.json".to_string()); } else { - configuration.schema = Some(format!("https://pgtools.dev/schemas/{VERSION}/schema.json")); + configuration.schema = Some(format!("https://pgtools.dev/{VERSION}/schema.json")); } let contents = serde_json::to_string_pretty(&configuration) diff --git a/docs/codegen/src/schema.rs b/docs/codegen/src/schema.rs index acfc42f1..3e430517 100644 --- a/docs/codegen/src/schema.rs +++ b/docs/codegen/src/schema.rs @@ -1,4 +1,4 @@ -use pgt_configuration::{PartialConfiguration, VERSION}; +use pgt_configuration::PartialConfiguration; use schemars::{ schema::{RootSchema, Schema, SchemaObject}, schema_for, @@ -10,25 +10,10 @@ use std::{fs, path::Path}; /// /// * `docs_dir`: Path to the docs directory. pub fn generate_schema(docs_dir: &Path) -> anyhow::Result<()> { - let schemas_dir = docs_dir.join("schemas"); - let latest_schema_dir = schemas_dir.join("latest"); - let latest_schema_path = latest_schema_dir.join("schema.json"); - - let version_schema_dir = schemas_dir.join(VERSION); - let version_schema_path = version_schema_dir.join("schema.json"); - - if !latest_schema_dir.exists() { - fs::create_dir_all(&latest_schema_dir)?; - } - - if !version_schema_dir.exists() { - fs::create_dir_all(&version_schema_dir)?; - } - + let schema_path = docs_dir.join("schema.json"); let schema_content = get_configuration_schema_content()?; - fs::write(latest_schema_path, &schema_content)?; - fs::write(version_schema_path, &schema_content)?; + fs::write(schema_path, &schema_content)?; Ok(()) } diff --git a/docs/schemas/0.0.0/schema.json b/docs/schema.json similarity index 100% rename from docs/schemas/0.0.0/schema.json rename to docs/schema.json diff --git a/docs/schemas/latest/schema.json b/docs/schemas/latest/schema.json deleted file mode 100644 index 8c478d0a..00000000 --- a/docs/schemas/latest/schema.json +++ /dev/null @@ -1,449 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Configuration", - "description": "The configuration that is contained inside the configuration file.", - "type": "object", - "properties": { - "$schema": { - "description": "A field for the [JSON schema](https://json-schema.org/) specification", - "type": [ - "string", - "null" - ] - }, - "db": { - "description": "The configuration of the database connection", - "anyOf": [ - { - "$ref": "#/definitions/DatabaseConfiguration" - }, - { - "type": "null" - } - ] - }, - "extends": { - "description": "A list of paths to other JSON files, used to extends the current configuration.", - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "files": { - "description": "The configuration of the filesystem", - "anyOf": [ - { - "$ref": "#/definitions/FilesConfiguration" - }, - { - "type": "null" - } - ] - }, - "linter": { - "description": "The configuration for the linter", - "anyOf": [ - { - "$ref": "#/definitions/LinterConfiguration" - }, - { - "type": "null" - } - ] - }, - "migrations": { - "description": "Configure migrations", - "anyOf": [ - { - "$ref": "#/definitions/MigrationsConfiguration" - }, - { - "type": "null" - } - ] - }, - "vcs": { - "description": "The configuration of the VCS integration", - "anyOf": [ - { - "$ref": "#/definitions/VcsConfiguration" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false, - "definitions": { - "DatabaseConfiguration": { - "description": "The configuration of the database connection.", - "type": "object", - "properties": { - "allowStatementExecutionsAgainst": { - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "connTimeoutSecs": { - "description": "The connection timeout in seconds.", - "type": [ - "integer", - "null" - ], - "format": "uint16", - "minimum": 0.0 - }, - "database": { - "description": "The name of the database.", - "type": [ - "string", - "null" - ] - }, - "host": { - "description": "The host of the database. Required if you want database-related features. All else falls back to sensible defaults.", - "type": [ - "string", - "null" - ] - }, - "password": { - "description": "The password to connect to the database.", - "type": [ - "string", - "null" - ] - }, - "port": { - "description": "The port of the database.", - "type": [ - "integer", - "null" - ], - "format": "uint16", - "minimum": 0.0 - }, - "username": { - "description": "The username to connect to the database.", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "FilesConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Will ignore files/folders that will match these patterns.", - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "include": { - "description": "A list of Unix shell style patterns. Will handle only those files/folders that will match these patterns.", - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "maxSize": { - "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons. Defaults to 1 MiB", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 1.0 - } - }, - "additionalProperties": false - }, - "LinterConfiguration": { - "type": "object", - "properties": { - "enabled": { - "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", - "type": [ - "boolean", - "null" - ] - }, - "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "include": { - "description": "A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns.", - "anyOf": [ - { - "$ref": "#/definitions/StringSet" - }, - { - "type": "null" - } - ] - }, - "rules": { - "description": "List of rules", - "anyOf": [ - { - "$ref": "#/definitions/Rules" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "MigrationsConfiguration": { - "description": "The configuration of the filesystem", - "type": "object", - "properties": { - "after": { - "description": "Ignore any migrations before this timestamp", - "type": [ - "integer", - "null" - ], - "format": "uint64", - "minimum": 0.0 - }, - "migrationsDir": { - "description": "The directory where the migration files are stored", - "type": [ - "string", - "null" - ] - } - }, - "additionalProperties": false - }, - "RuleConfiguration": { - "anyOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - }, - { - "$ref": "#/definitions/RuleWithNoOptions" - } - ] - }, - "RulePlainConfiguration": { - "type": "string", - "enum": [ - "warn", - "error", - "info", - "off" - ] - }, - "RuleWithNoOptions": { - "type": "object", - "required": [ - "level" - ], - "properties": { - "level": { - "description": "The severity of the emitted diagnostics by the rule", - "allOf": [ - { - "$ref": "#/definitions/RulePlainConfiguration" - } - ] - } - }, - "additionalProperties": false - }, - "Rules": { - "type": "object", - "properties": { - "all": { - "description": "It enables ALL rules. The rules that belong to `nursery` won't be enabled.", - "type": [ - "boolean", - "null" - ] - }, - "recommended": { - "description": "It enables the lint rules recommended by Postgres Tools. `true` by default.", - "type": [ - "boolean", - "null" - ] - }, - "safety": { - "anyOf": [ - { - "$ref": "#/definitions/Safety" - }, - { - "type": "null" - } - ] - } - }, - "additionalProperties": false - }, - "Safety": { - "description": "A list of rules that belong to this group", - "type": "object", - "properties": { - "addingRequiredField": { - "description": "Adding a new column that is NOT NULL and has no default value to an existing table effectively makes it required.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "all": { - "description": "It enables ALL rules for this group.", - "type": [ - "boolean", - "null" - ] - }, - "banDropColumn": { - "description": "Dropping a column may break existing clients.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "banDropNotNull": { - "description": "Dropping a NOT NULL constraint may break existing clients.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "banDropTable": { - "description": "Dropping a table may break existing clients.", - "anyOf": [ - { - "$ref": "#/definitions/RuleConfiguration" - }, - { - "type": "null" - } - ] - }, - "recommended": { - "description": "It enables the recommended rules for this group", - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - }, - "StringSet": { - "type": "array", - "items": { - "type": "string" - }, - "uniqueItems": true - }, - "VcsClientKind": { - "oneOf": [ - { - "description": "Integration with the git client as VCS", - "type": "string", - "enum": [ - "git" - ] - } - ] - }, - "VcsConfiguration": { - "description": "Set of properties to integrate with a VCS software.", - "type": "object", - "properties": { - "clientKind": { - "description": "The kind of client.", - "anyOf": [ - { - "$ref": "#/definitions/VcsClientKind" - }, - { - "type": "null" - } - ] - }, - "defaultBranch": { - "description": "The main branch of the project", - "type": [ - "string", - "null" - ] - }, - "enabled": { - "description": "Whether we should integrate itself with the VCS client", - "type": [ - "boolean", - "null" - ] - }, - "root": { - "description": "The folder where we should check for VCS files. By default, we will use the same folder where `postgrestools.jsonc` was found.\n\nIf we can't find the configuration, it will attempt to use the current working directory. If no current working directory can't be found, we won't use the VCS integration, and a diagnostic will be emitted", - "type": [ - "string", - "null" - ] - }, - "useIgnoreFile": { - "description": "Whether we should use the VCS ignore file. When [true], we will ignore the files specified in the ignore file.", - "type": [ - "boolean", - "null" - ] - } - }, - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 3597e08c..464aab00 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -28,12 +28,4 @@ plugins: markdown_extensions: - admonition - # - pymdownx.highlight: - # anchor_linenums: true - # line_spans: __span - # pygments_lang_class: true - # - pymdownx.inlinehilite - # - pymdownx.snippets - # - pymdownx.superfences - # - pymdownx.tabbed: - # alternate_style: true + - mike diff --git a/pyproject.toml b/pyproject.toml index 73ee0fa8..41317471 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ description = "A collection of language tools and a Language Server Protocol (LS readme = "README.md" requires-python = ">=3.13" dependencies = [ + "mike>=2.1.3", "mkdocs>=1.6.1", "mkdocs-github-admonitions-plugin>=0.0.3", ]