Esempio n. 1
0
// generate each os-arch address
func (r *Repo) Pub(goos, arch string) *Publish {
	link := goutils.StrFormat("http://{domain}/gorelease/{org}/{name}/{branch}/{os}-{arch}/{name}",
		map[string]interface{}{
			"domain": r.Domain,
			"org":    r.Org,
			"name":   r.Name,
			"branch": r.Branch,
			"os":     goos,
			"arch":   arch,
		})
	if goos == "windows" {
		link += ".exe"
	}
	return &Publish{
		OS:     goos,
		Arch:   arch,
		Branch: r.Branch,
		Link:   link,
	}
}
Esempio n. 2
0
func (t *Github) UpdateFile(owner, repo string, file *CommitFile) error {
	fc, err := t.GetFile(owner, repo, file.Path)
	if err != nil {
		return err
	}
	var commitBody = map[string]string{}
	commitBody["sha"] = fc.Sha
	commitBody["message"] = file.Message
	commitBody["content"] = base64.StdEncoding.EncodeToString([]byte(file.Content))
	if file.Branch != "" {
		commitBody["branch"] = file.Branch
	}

	data, _ := json.Marshal(commitBody)
	rd := bytes.NewBuffer(data)
	return t.doRequest("PUT",
		goutils.StrFormat("/repos/{owner}/{repo}/contents/{path}", map[string]interface{}{
			"owner": owner,
			"repo":  repo,
			"path":  file.Path}),
		nil, rd, nil)
}