Skip to content

A deployment method for Publish to upload files using FTP

License

Notifications You must be signed in to change notification settings

dinsen/FTPPublishDeploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FTPPublishDeploy

Swift 5.1 Swift Package Manager Mac & Linux Publish Deploy Twitter: @BrianDinsen

A deployment method for Publish to upload files using FTP.

Installation

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"
            ]
        )
    ]
    ...
)

Usage

There is 3 ways to declare your connection information.

  1. Declare it directly into the FTPConnection struct:
let ftpConnection = FTPConnection(username: "batman",
                                  password: "robin",
                                  host: "my.host.com",
                                  port: 21)
  1. 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)
}
  1. 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"))
])

Acknowledgement

Thanks to John Sundell (@johnsundell) for creating Publish

License

MIT License

About

A deployment method for Publish to upload files using FTP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages