Skip to content

Commit ace92fb

Browse files
committed
optimize release
1 parent e9e15d9 commit ace92fb

5 files changed

Lines changed: 18 additions & 28 deletions

File tree

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
default: build
1+
default: release
22

3-
build:
4-
goreleaser release --snapshot --clean && mv podwise-skills.tar.gz ./dist/
3+
release:
4+
@$(if $(strip $(version)),:,$(error version is required: make release version=v1.2.3))
5+
git tag $(version) && git push origin $(version)
6+
goreleaser release --snapshot --clean

internal/episode/followed.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,9 @@ func (r *FollowedResult) FormatText(date string, days int) string {
5454
if ep.Language != nil && *ep.Language != "" {
5555
fmt.Fprintf(&sb, "- **Language:** %s\n", *ep.Language)
5656
}
57-
processedLabel := "No"
58-
if ep.Transcribed {
59-
processedLabel = "Yes"
60-
}
61-
fmt.Fprintf(&sb, "- **Processed:** %s\n", processedLabel)
57+
fmt.Fprintf(&sb, "- **Processed:** %s\n", utils.BoolToYesNo(ep.Transcribed))
6258
fmt.Fprintf(&sb, "- **Episode URL:** %s\n", BuildEpisodeURL(ep.Seq))
63-
readLabel := "No"
64-
if ep.IsRead {
65-
readLabel = "Yes"
66-
}
67-
fmt.Fprintf(&sb, "- **Read:** %s\n", readLabel)
59+
fmt.Fprintf(&sb, "- **Read:** %s\n", utils.BoolToYesNo(ep.IsRead))
6860
sb.WriteString("\n")
6961
}
7062
return sb.String()

internal/episode/popular.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,11 @@ type PopularEpisodeJSON struct {
6868
func (r *PopularResult) FormatJSON() ([]byte, error) {
6969
items := make([]PopularEpisodeJSON, 0, len(r.Episodes))
7070
for _, ep := range r.Episodes {
71-
isYouTube := "No"
72-
if ep.LinkType == "youtube" {
73-
isYouTube = "Yes"
74-
}
7571
items = append(items, PopularEpisodeJSON{
7672
Title: ep.Title,
7773
PodcastName: ep.PodcastName,
7874
EpisodeURL: BuildEpisodeURL(ep.Seq),
79-
IsYouTube: isYouTube,
75+
IsYouTube: utils.BoolToYesNo(ep.LinkType == "youtube"),
8076
Duration: utils.FormatDuration(time.Duration(ep.Duration) * time.Second),
8177
})
8278
}

internal/podcast/episodes.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,9 @@ func (r *PodcastEpisodesResult) FormatText(date string, days int) string {
5757
if ep.Language != nil && *ep.Language != "" {
5858
fmt.Fprintf(&sb, "- **Language:** %s\n", *ep.Language)
5959
}
60-
processedLabel := "No"
61-
if ep.Transcribed {
62-
processedLabel = "Yes"
63-
}
64-
fmt.Fprintf(&sb, "- **Processed:** %s\n", processedLabel)
60+
fmt.Fprintf(&sb, "- **Processed:** %s\n", utils.BoolToYesNo(ep.Transcribed))
6561
fmt.Fprintf(&sb, "- **Episode URL:** %s\n", episode.BuildEpisodeURL(ep.Seq))
66-
readLabel := "No"
67-
if ep.IsRead {
68-
readLabel = "Yes"
69-
}
70-
fmt.Fprintf(&sb, "- **Read:** %s\n", readLabel)
62+
fmt.Fprintf(&sb, "- **Read:** %s\n", utils.BoolToYesNo(ep.IsRead))
7163
sb.WriteString("\n")
7264
}
7365
return sb.String()

internal/utils/utils.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,11 @@ func NormalizeDurationString(value string) string {
5454
s := totalSeconds % 60
5555
return fmt.Sprintf("%02d:%02d:%02d", h, m, s)
5656
}
57+
58+
// BoolToYesNo converts a boolean value to "Yes" or "No".
59+
func BoolToYesNo(b bool) string {
60+
if b {
61+
return "Yes"
62+
}
63+
return "No"
64+
}

0 commit comments

Comments
 (0)