func deploy() error {
	if len(os.Args) < 3 {
		return errors.New("invalid number of arguments")
	}
	pluginID := os.Args[1]
	bundlePath := os.Args[2]
	siteURL := os.Getenv("MM_SERVICESETTINGS_SITEURL")
	adminToken := os.Getenv("MM_ADMIN_TOKEN")
	adminUsername := os.Getenv("MM_ADMIN_USERNAME")
	adminPassword := os.Getenv("MM_ADMIN_PASSWORD")
	copyTargetDirectory, _ := filepath.Abs("../mattermost-server")
	if siteURL != "" {
		client := model.NewAPIv4Client(siteURL)
		if adminToken != "" {
			log.Printf("Authenticating using token against %s.", siteURL)
			client.SetToken(adminToken)
			return uploadPlugin(client, pluginID, bundlePath)
		}
		if adminUsername != "" && adminPassword != "" {
			client := model.NewAPIv4Client(siteURL)
			log.Printf("Authenticating as %s against %s.", adminUsername, siteURL)
			_, resp := client.Login(adminUsername, adminPassword)
			if resp.Error != nil {
				return errors.Wrapf(resp.Error, "failed to login as %s: %s", adminUsername, resp.Error.Error())
			}
			return uploadPlugin(client, pluginID, bundlePath)
		}
	}
	_, err := os.Stat(copyTargetDirectory)
	if os.IsNotExist(err) {
		return errors.New("no supported deployment method available, please install plugin manually")
	} else if err != nil {
		return errors.Wrapf(err, "failed to stat %s", copyTargetDirectory)
	}
	log.Printf("Installing plugin to mattermost-server found in %s.", copyTargetDirectory)
	log.Print("Server restart required to load updated plugin.")
	return copyPlugin(pluginID, copyTargetDirectory, bundlePath)
}
deploy handles deployment of the plugin to a development server.
package main
import (
	"fmt"
	"log"
	"os"
	"path/filepath"
	"github.com/mattermost/mattermost-server/v5/model"
	"github.com/mholt/archiver/v3"
	"github.com/pkg/errors"
)
func main() {
	err := deploy()
	if err != nil {
		fmt.Printf("Failed to deploy: %s\n", err.Error())
		fmt.Println()
		fmt.Println("Usage:")
		fmt.Println("    deploy <plugin id> <bundle path>")
		os.Exit(1)
	}
}