Static site deployment with Swift using John Sundell's Publish


If you want to deploy your static site directly from John Sundell’s Publish on Cloudflare Pages using your Git Repo you can do so directly with the build settings as below:

Using earlier versions of Publish with Swift 5.2 or earlier:

Build command:
Build output directory: Output
Root directory: /

At the time of writing, Cloudflare Pages seems to have Swift 5.2 installed by default and your Swift code will be compiled automatically as part of the “Building the application” phase (though it’s not supposed to as you haven’t given any command to build).

If you are on Swift 5.3 or later the package may not compile due to this automatic compilation and your deployment won’t complete.
One way around this is to compile your code locally and “push” the Output folder into your Git Repo and use the build settings as shown below:

Build command:
Build output directory: /
Root directory: /Output