Skip to content

Commit

Permalink
Add publish-release and release notes to build targets
Browse files Browse the repository at this point in the history
  • Loading branch information
puerco committed Apr 18, 2023
1 parent 6955d80 commit de7d735
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cmd/publish-release/cmd/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func init() {
githubPageCmd.PersistentFlags().StringVar(
&ghPageOpts.sbomFormat,
"sbom-format",
"json",
announce.FormatJSON,
"format to use for the SBOM [json|tag-value]",
)
githubPageCmd.PersistentFlags().StringVar(
Expand Down Expand Up @@ -283,7 +283,7 @@ func runGithubPage(opts *githubPageCmdLineOptions) (err error) {
RepoDirectory: opts.repoPath,
Assets: assets,
Tag: commandLineOpts.tag,
Format: opts.sbomFormat,
Format: announce.SBOMFormat(opts.sbomFormat),
})
if err != nil {
return fmt.Errorf("generating sbom: %w", err)
Expand Down
2 changes: 2 additions & 0 deletions compile-release-tools
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ RELEASE_TOOLS=(
krel
kubepkg
schedule-builder
publish-release
release-notes
)

setup_env() {
Expand Down
17 changes: 12 additions & 5 deletions pkg/announce/github_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,19 @@ type GitHubPageOptions struct {
Substitutions map[string]string
}

type SBOMFormat string

const (
FormatJSON = "json"
FormatTagValue = "tag-value"
)

type SBOMOptions struct {
ReleaseName string
Repo string
RepoDirectory string
Tag string // Version Tag
Format string // "tag-value" | "json"
Tag string // Version Tag
Format SBOMFormat // "tag-value" | "json"
Assets []Asset
}

Expand Down Expand Up @@ -173,12 +180,12 @@ func GenerateReleaseSBOM(opts *SBOMOptions) (string, error) {

var renderer serialize.Serializer
switch opts.Format {
case "json":
case FormatJSON:
renderer = &serialize.JSON{}
case "tag-value":
case FormatTagValue:
renderer = &serialize.TagValue{}
default:
return "", errors.New("invalid SBOM format, must be one of json, tag-value")
return "", fmt.Errorf("invalid SBOM format, must be one of %s, %s", FormatJSON, FormatTagValue)
}

markup, err := renderer.Serialize(doc)
Expand Down

0 comments on commit de7d735

Please sign in to comment.