deploy

package
v0.0.0-...-3a253d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteDeployHooks

func ExecuteDeployHooks(sshClient *ssh.Client, config *Config) error

ExecuteDeployHooks 执行 pre-hook / 更新 currentLink / post-hook

func PackDir

func PackDir(config *Config) (string, error)

PackDir 压缩目录 dir 为 tar.gz,显示漂亮进度条

func PostDeployHost

func PostDeployHost(sshClient *ssh.Client, localTarGz string, config *Config) error

PostDeployHost 在远程服务器上执行部署

Types

type Config

type Config struct {
	Dir         string   `yaml:"dir"`         // 部署根目录(本地或远程路径)
	Version     string   `yaml:"version"`     // 部署版本号,例如 v1.0.0 或 20260102153000
	Include     []string `yaml:"include"`     // 需要包含的文件或目录列表
	Exclude     []string `yaml:"exclude"`     // 需要排除的文件或目录列表
	RemoteRepo  string   `yaml:"remoteRepo"`  // 远程存放版本的目录,例如 /data/app/releases
	CurrentLink string   `yaml:"currentLink"` // 当前软链接路径,例如 /data/app/current
	HookPre     string   `yaml:"hookPre"`     // 部署前执行的钩子命令
	HookPost    string   `yaml:"hookPost"`    // 部署后执行的钩子命令
}

Config 部署配置结构体 包含本地、远程、版本、钩子等部署相关信息

func Load

func Load(cmd *cli.Command) *Config
func (c *Config) GetCurrentLink() string

GetCurrentLink 获取当前软链接路径 如果路径没有以 / 开头,会自动加上 / 例如 currentLink = "current" → "/current"

func (*Config) GetHookPost

func (c *Config) GetHookPost() string

GetHookPost 获取部署后钩子命令

func (*Config) GetHookPre

func (c *Config) GetHookPre() string

GetHookPre 获取部署前钩子命令

func (*Config) GetRemoteRepo

func (c *Config) GetRemoteRepo() string

GetRemoteRepo 获取远程存放版本的目录路径 如果路径没有以 / 开头,会自动加上 / 例如 remoteRepo = "data/app/releases" → "/data/app/releases"

func (*Config) GetVersion

func (c *Config) GetVersion() string

GetVersion 获取版本号

func (*Config) GetVersionRemoteDir

func (c *Config) GetVersionRemoteDir() string

GetVersionRemoteDir 获取远程版本目录完整路径 例如 /data/app/releases/v1.0.0

func (*Config) Validate

func (c *Config) Validate() error

Validate 校验配置参数是否合法 检查必须字段是否为空,避免部署失败

Source Files

  • confg.go
  • execute.go
  • load.go
  • pack.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL