Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
kazeburo committed Feb 5, 2021
1 parent add3390 commit 7f0afc0
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: test
on:
push:
branches:
- "**"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.15

- name: test
run: make check
17 changes: 17 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
builds:
- binary: sacloudns
goos:
- linux
- darwin
goarch:
- amd64
- arm64
ldflags:
- -w -s -X main.version={{.Version}}
archives:
- format: zip
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
release:
github:
owner: kazeburo
name: sacloudns
29 changes: 24 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"runtime"
"strings"
"time"

Expand All @@ -17,6 +18,12 @@ import (
"github.com/sacloud/libsacloud/v2/sacloud/types"
)

// version by Makefile
var version string

type verOpts struct {
}

type listOpts struct {
}

Expand Down Expand Up @@ -52,11 +59,12 @@ type rdelOpts struct {
}

type mainOpts struct {
ListCmd listOpts `command:"list" description:"list zones"`
ZoneCmd zoneOpts `command:"zone" description:"describe zone"`
RAddCmd raddOpts `command:"radd" description:"add a record"`
RSetCmd rsetOpts `command:"rset" description:"replace records or add a record"`
RDelCmd rdelOpts `command:"rdelete" description:"delete a record"`
ListCmd listOpts `command:"list" description:"list zones"`
ZoneCmd zoneOpts `command:"zone" description:"describe zone"`
RAddCmd raddOpts `command:"radd" description:"add a record"`
RSetCmd rsetOpts `command:"rset" description:"replace records or add a record"`
RDelCmd rdelOpts `command:"rdelete" description:"delete a record"`
VersionCMD verOpts `command:"version" description:"display version"`
}

func outJSON(result interface{}) error {
Expand Down Expand Up @@ -346,6 +354,17 @@ func (opts *rdelOpts) Execute(args []string) error {
return outJSON(result)
}

func (opts *verOpts) Execute(args []string) error {
fmt.Printf(`%s %s
Compiler: %s %s
`,
os.Args[0],
version,
runtime.Compiler,
runtime.Version())
return nil
}

func main() {
err := godotenv.Load()
if err != nil {
Expand Down

0 comments on commit 7f0afc0

Please sign in to comment.