Skip to content

Commit

Permalink
Merge pull request #1 from yktakaha4/add-ci
Browse files Browse the repository at this point in the history
add ci
  • Loading branch information
yktakaha4 authored Dec 20, 2022
2 parents c0ff9de + 27c6ace commit 6e26567
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .envrc.sample
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export GITHUB_ACCESS_TOKEN=
export KUNITORI_GITHUB_ACCESS_TOKEN=
export KUNITORI_USE_GIT_COMMAND=
export KUNITORI_SKIP_REQUEST_GITHUB_API=
55 changes: 55 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check

on: pull_request

jobs:
build:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.19

- run: make build

fmt:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.19

- run: make fmt

vet:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.19

- run: make vet

test:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0

- uses: actions/setup-go@v3
with:
go-version: 1.19

- run: make test
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*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v3
with:
go-version: 1.19

- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ go.work
# End of https://www.toptal.com/developers/gitignore/api/go

.envrc
/chart.html
/generate.json
/*.html
/*.json
/kunitori
dist/
26 changes: 26 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
main: ./cmd/kunitori
binary: kunitori
ldflags:
- -s -w
- -X main.Version={{.Version}}
- -X main.ShortCommit={{.ShortCommit}}
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
skip: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ testall:

.PHONY: build
build:
go build -o ./bin/kunitori -v ./cmd/kunitori/
go build -v ./cmd/kunitori/

.PHONY: fmt
fmt:
Expand Down
2 changes: 0 additions & 2 deletions bin/.gitignore

This file was deleted.

22 changes: 16 additions & 6 deletions cmd/kunitori/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import (
"time"
)

var (
Version = "unset"
ShortCommit = "unset"
)

type arrayFlags []string

func (i *arrayFlags) String() string {
Expand All @@ -31,9 +36,14 @@ func main() {
log.SetOutput(io.Discard)
}

defaultHelpMessage := `Kunitori
- generate ... generate chart
`
defaultHelpMessage := fmt.Sprintf(`Kunitori (国盗り)
Version: %v
Commit: %v
SubCommands:
generate ... generate Kunitori chart
`, Version, ShortCommit)

if len(os.Args) < 2 {
fmt.Print(defaultHelpMessage)
Expand All @@ -47,7 +57,7 @@ func main() {
generateJson := generateCmd.Bool("json", false, "export as json format")
generateUrl := generateCmd.String("url", "", "repository url")
generatePath := generateCmd.String("path", "", "repository path")
generateRegion := generateCmd.String("region", "JP", "chart region (default: JP)")
generateRegion := generateCmd.String("region", "JP", "chart region")
generateSince := generateCmd.String(
"since",
"",
Expand All @@ -61,12 +71,12 @@ func main() {
generateInterval := generateCmd.Duration(
"interval",
time.Hour*24*30,
"commit pick interval (default: 30 days)",
"commit pick interval",
)
generateLimit := generateCmd.Int(
"limit",
12,
fmt.Sprintf("commit pick limit (default: 12, max: %v)", pkg.SearchCommitMaxLimit),
"commit pick limit",
)

var filters arrayFlags
Expand Down
2 changes: 1 addition & 1 deletion pkg/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"
)

const GitHubAccessTokenKey = "GITHUB_ACCESS_TOKEN"
const GitHubAccessTokenKey = "KUNITORI_GITHUB_ACCESS_TOKEN"
const KunitoriSkipRequestGitHubApi = "KUNITORI_SKIP_REQUEST_GITHUB_API"

func FindLoginByEmail(email string) (string, error) {
Expand Down

0 comments on commit 6e26567

Please sign in to comment.