PUBLISHING DEX ONLINE


Dexweb publishes a dex online in one step. dexgen builds dex in gen/. dexweb publishes it. Publishing is set with publish JSON object in config.json. Publishing starts from run.py. Available from v4.2.5.

1. Add publish JSON object to config.json. Publish JSON object must contain address (dest) of the repository the dex is published to:

"publish": {"dest": "git@github.com:username/username.github.io.git", "branch": "main"}

2. Add this line to run.py:

dexweb.Dexweb().publish()

So run.py becomes:

from dexweb import dexgen, dexweb
dex = dexgen.Dexgen()
dexweb.Dexweb().publish()

3. Run

python run.py

Dexweb builds the dex and copies files in gen/ to the root of the online repository. It commits them and pushes. GitHub Pages then serves the updated dex at the repository's URL. publish() returns True when the dex is published and False when it is not with a message saying why.

Publish options
publish in config.json is an object with these options. All are optional except path for the "folder" method.

method: 'git' or 'folder'. Default value: 'git'.
'git' commits the dex to a git repository and pushes it
'folder' copies gen/ into a folder (specified by path)

dest: where the dex is published.

For method 'git', either a repository address ('git@github.com:username/username.github.io.git') or a local folder that is the root of a git repository ('..'). If an address is given, dexweb keeps its own copy of the repository in .publish/ in the dex root, so the dex folder does not need to be a git repository. Parent folders are never searched.

branch: git branch to publish to. Default value: repository's current branch.

remote: name of the repository's remote to push to. Default value: 'origin'.

site_path: folder inside the repository where the dex is copied. Default value: '.', the repository root. Use 'docs' for GitHub Pages sites published from the /docs folder.

message: commit message. {} is replaced with the dex name. Default value: 'Publish {}'. The time of publishing (UTC) is always added, for example Publish Dexweb Docs (2026-10-01T14:09:02Z).

path: folder that gen/ is copied into, for method 'folder', absolute or relative to the dex root. Required for method 'folder'.

Examples
Publish to a GitHub Pages repository:

"publish": {"dest": "git@github.com:username/username.github.io.git", "branch": "main"}

Publish to the /docs folder of a repository:

"publish": {"dest": "git@github.com:username/project.git", "branch": "main", "site_path": "docs"}

The dex root folder is itself the repository that is published:

"publish": {"branch": "main"}

Publish to a folder, for example a web server's site folder, a synced folder or a USB drive:

"publish": {"method": "folder", "path": "/var/www/mydex"}

How publishing works
For method 'git', publish() finds the repository (cloning it into .publish/ the first time if dest is an address, and updating that copy before every later publish), copies the files in gen/ into the repository root (or site_path), commits only those files, and pushes. Other files in the dex root, such as data.json, config.json and run.py, are never committed by publish().

Publishing never deletes files that are already in the repository or folder; it only adds and overwrites. If nothing changed, no commit is made. Publishing never force pushes: if someone else published first, the push is refused and dexweb asks you to pull their changes and publish again.

Git uses your own credentials (an SSH key or a credential helper). Never put passwords or tokens in config.json: it is part of the dex and may be public.

If the dex root folder is itself in a git repository and dest is an address, add .publish/ to that repository's .gitignore.

Requirements
Method 'git' needs git installed and able to push to the repository. Method 'folder' needs nothing beyond dexweb. No new Python packages are required.

When a dex is not published
In every case below, the dex is still built in gen/ and run.py finishes normally. publish() prints the reason and returns False:

1. config.json has no publish.

2. gen/ is empty: build the dex first.

3. dest is not set and the dex root folder is not the root of a git repository. A git repository in a parent folder is never used; to publish to it, set dest to it, for example '..'.

4. git is not installed.

5. The push was refused, usually because someone else published first.

Backwards compatibility
dexgen is unchanged: it only builds the dex and never publishes. Every dex builds exactly as before, and a run.py with only the two dexgen lines never publishes, even if config.json has publish. Dexs without publish need no changes.

dexweb.Dexweb() takes no arguments and reads the dex name from config.json. The earlier Dexweb(dexname) form is removed; it did nothing before v4.2.5.

Manual hosting still works: see Dex Hosting.








BACK TO DEXWEB DOCS