// Compress make archive from repository branch func (repo *Repository) Compress(config *Config, d driver.Driver, p *packages.Composer) error { // Prepare path and archive path gd := &download.Git{ Name: p.Name, Version: p.Version, URL: repo.URL, Source: p.Source, DistDir: config.DistDir, } gd.Prepare() // Prepare compression cz := compress.Zip{ SourcePath: gd.SourcePath, } cz.Prepare() // Run download if !gd.PathExist && !cz.IsExist { err := gd.Run() if err != nil { return err } } // Run compression if gd.PathExist && !cz.IsExist { err := cz.Run() if err != nil { return err } } if cz.IsExist { host := config.File.Homepage if config.File.Archive.PrefixURL != "" { host = config.File.Archive.PrefixURL } p.Dist = map[string]string{ "type": cz.Format, "url": host + "/" + path.Join(config.File.Archive.Directory, strings.Replace(cz.TargetPath, gd.DistDir, "", -1)), "reference": d.GetReference(), "shasum": hashFile(cz.TargetPath), } } return nil }