Skip to content

Commit cd5120f

Browse files
authored
Add version sub-command for goplay (#7)
1 parent 7002632 commit cd5120f

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

.github/workflows/pull-request.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
run: |
2222
sudo apt-get update -y
2323
sudo apt install libasound2-dev -y
24-
go build -o bin/goplay .
24+
go build -ldflags '-X github.com/linuxsuren/cobra-extension/version.version=${{ github.ref_name }} -X github.com/linuxsuren/cobra-extension/version.commit=${{ github.sha }}' -o bin/goplay .
2525
go test ./...
2626
2727
build-darwin:
@@ -37,7 +37,7 @@ jobs:
3737
uses: actions/checkout@v2.3.5
3838
- name: Build
3939
run: |
40-
go build -o bin/goplay .
40+
go build -ldflags '-X github.com/linuxsuren/cobra-extension/version.version=${{ github.ref_name }} -X github.com/linuxsuren/cobra-extension/version.commit=${{ github.sha }}' -o bin/goplay .
4141
go test ./...
4242
4343
build-win:
@@ -53,5 +53,5 @@ jobs:
5353
uses: actions/checkout@v2.3.5
5454
- name: Build
5555
run: |
56-
go build -o bin/goplay .
56+
go build -ldflags '-X github.com/linuxsuren/cobra-extension/version.version=${{ github.ref_name }} -X github.com/linuxsuren/cobra-extension/version.commit=${{ github.sha }}' -o bin/goplay .
5757
go test ./...

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: |
2424
sudo apt-get update -y
2525
sudo apt install libasound2-dev -y
26-
GOENABLE=0 go build -o bin/goplay .
26+
GOENABLE=0 go build -ldflags '-X github.com/linuxsuren/cobra-extension/version.version=${{ github.ref_name }} -X github.com/linuxsuren/cobra-extension/version.commit=${{ github.sha }}' -o bin/goplay .
2727
cd bin && tar czvf goplay-linux-amd64.tar.gz goplay
2828
gh release upload ${{ github.ref_name }} goplay-linux-amd64.tar.gz
2929
BuildOnDarwin:
@@ -40,6 +40,6 @@ jobs:
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
4242
run: |
43-
GOENABLE=0 go build -o bin/goplay .
43+
GOENABLE=0 go build -ldflags '-X github.com/linuxsuren/cobra-extension/version.version=${{ github.ref_name }} -X github.com/linuxsuren/cobra-extension/version.commit=${{ github.sha }}' -o bin/goplay .
4444
cd bin && tar czvf goplay-darwin-amd64.tar.gz goplay
4545
gh release upload ${{ github.ref_name }} goplay-darwin-amd64.tar.gz

cmd/play.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/linuxsuren/goplay/pkg/advanced_ui"
88
"github.com/linuxsuren/goplay/pkg/rss"
99
exec2 "github.com/linuxsuren/http-downloader/pkg/exec"
10+
extver "github.com/linuxsuren/cobra-extension/version"
1011
"github.com/spf13/cobra"
1112
"os/exec"
1213
"strings"
@@ -23,6 +24,8 @@ func NewPlayCommand() (cmd *cobra.Command) {
2324
Args: cobra.MinimumNArgs(1),
2425
RunE: opt.runE,
2526
}
27+
28+
cmd.AddCommand(extver.NewVersionCmd("linuxsuren", "goplay", "goplay", nil))
2629
return
2730
}
2831

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/faiface/beep v1.1.0
99
github.com/gdamore/tcell v1.3.0
1010
github.com/ghodss/yaml v1.0.0
11+
github.com/linuxsuren/cobra-extension v0.0.11
1112
github.com/linuxsuren/http-downloader v0.0.50
1213
github.com/spf13/cobra v1.2.1
1314
github.com/spf13/viper v1.9.0

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
204204
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
205205
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
206206
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
207+
github.com/google/go-github/v29 v29.0.3 h1:IktKCTwU//aFHnpA+2SLIi7Oo9uhAzgsdZNbcAqhgdc=
207208
github.com/google/go-github/v29 v29.0.3/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
209+
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
208210
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
209211
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
210212
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
@@ -323,6 +325,7 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
323325
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
324326
github.com/linuxsuren/cobra-extension v0.0.6/go.mod h1:qcEJv7BbL0UpK6MbrTESP/nKf1+z1wQdMAnE1NBl3QQ=
325327
github.com/linuxsuren/cobra-extension v0.0.10/go.mod h1:nDsXgvm0lSWVV+byAEfwhIGFDoIp0Sq9wkfNUDBp5do=
328+
github.com/linuxsuren/cobra-extension v0.0.11 h1:Z2Sx8dBPvJK3s3loguFXJtrtiwh1Od3O2xoB6vCOl5M=
326329
github.com/linuxsuren/cobra-extension v0.0.11/go.mod h1:gn69Dtq72JCGZbjW46c14MoE0z/BtDAQWV9Jvr9KczY=
327330
github.com/linuxsuren/http-downloader v0.0.2-0.20201207132639-19888a6beaec/go.mod h1:zRZY9FCDBuYNDxbI2Ny5suasZsMk7J6q9ecQ3V3PIqI=
328331
github.com/linuxsuren/http-downloader v0.0.6/go.mod h1:xxgh2OE7WGL9TwDE9L8Gh7Lqq9fFPuHbh5tofUitEfE=
@@ -520,6 +523,7 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
520523
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
521524
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
522525
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
526+
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ=
523527
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
524528
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
525529
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=

pkg/data/source_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import (
88
func TestGetRSSSources(t *testing.T) {
99
items, err := GetRSSSources()
1010
assert.Nil(t, err)
11-
assert.Equal(t, 8, len(items))
11+
assert.Equal(t, 9, len(items))
1212
}

0 commit comments

Comments
 (0)