A deployment method for Publish to upload files using FTP.
Add FTPPublishDeploy to your Package.swift
file.
let package = Package(
...
dependencies: [
.package(url: "https://github.com/dinsen/ftppublishdeploy", from: "0.1.0")
],
targets: [
.target(
...
dependencies: [
...
"FTPPublishDeploy"
]
)
]
...
)
There is 3 ways to declare your connection information.
- Declare it directly into the
FTPConnection
struct:
let ftpConnection = FTPConnection(username: "batman",
password: "robin",
host: "my.host.com",
port: 21)
- Create a JSON file called
ftp.json
in the root of your project:
{
"username": "batman",
"password": "robin",
"host": "my.host.com",
"port": 21
}
Remember to add the file to .gitignore to prevent your connection information being exposed!
Then use Files to locate the file:
import Files
...
let file = try File(path: #file)
guard let ftpConnection = try FTPConnection(file: file) else {
throw FilesError(path: file.path, reason: LocationErrorReason.missing)
}
- Use environment declared in your CI service like Bitrise
let environment = ProcessInfo.processInfo.environment
guard let ftpConnection = try FTPConnection(environment: environment) else {
return
}
Last you can then declare your deployment method in your pipeline:
import FTPPublishDeploy
...
try Website().publish(using: [
...
.deploy(using: .ftp(connection: ftpConnection, sourcePath: "public_html/brian"))
])
Thanks to John Sundell (@johnsundell) for creating Publish
MIT License