-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.go
37 lines (31 loc) · 1.03 KB
/
release.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package slugcmplr
import (
"context"
"fmt"
heroku "github.com/heroku/heroku-go/v5"
)
// ReleaseCmd wraps up all the information required to release a slug that has
// been uploaded to a Heroku application.
type ReleaseCmd struct {
Heroku *heroku.Service
Application string
SlugID string
Commit string
}
// ReleaseInfo contains the ID and OutputStreamURL of an attempted release.
type ReleaseInfo struct {
ID string
OutputStreamURL *string
}
// Execute will attempt to release a given slug to an application, returning
// the release ID and and OutputStreamURL, if there is one.
func (r *ReleaseCmd) Execute(ctx context.Context, _ Outputter) (*ReleaseInfo, error) {
release, err := r.Heroku.ReleaseCreate(ctx, r.Application, heroku.ReleaseCreateOpts{
Slug: r.SlugID,
Description: heroku.String(fmt.Sprintf("Deployed %v", r.Commit[:8])),
})
if err != nil {
return nil, fmt.Errorf("error release slug: %w", err)
}
return &ReleaseInfo{ID: release.ID, OutputStreamURL: release.OutputStreamURL}, nil
}