diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bbdcd1..9b71827 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,9 @@ -name: goreleaser +name: release on: - push: + push: tags: - - '*' + - "*" permissions: contents: write @@ -12,25 +12,21 @@ jobs: goreleaser: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - - - name: Set up Go + - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 - - - name: Login to GitHub Container Registry + go-version: 1.19 + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Run GoReleaser + - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: distribution: goreleaser @@ -38,3 +34,7 @@ jobs: args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Update krew-index + uses: rajatjindal/krew-release-bot@v0.0.43 + with: + krew_template_file: .krew/tail.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 541c4ac..d3ed7b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,9 +3,9 @@ name: test on: push: tags: - - v* + - "**" branches: - - main + - master pull_request: permissions: @@ -18,6 +18,6 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version-file: go.mod - cache: true + go-version-file: go.mod + cache: true - run: go test -v ./... diff --git a/.goreleaser.yml b/.goreleaser.yml index 341a41b..a227786 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -13,7 +13,6 @@ builds: - linux goarch: - amd64 - - arm - arm64 goamd64: - v1 @@ -21,6 +20,18 @@ builds: - v3 env: - CGO_ENABLED=0 + ldflags: + - -s -w + - -X github.com/boz/tail/version.Version={{.Tag}} + - -X github.com/boz/tail/version.Commit={{.ShortCommit}} + - -X github.com/boz/tail/version.Date={{.Date}} + - -X github.com/boz/tail/version.BuiltBy=GoReleaser + - -X github.com/boz/tail/version.OsName={{.Os}} + - -X github.com/boz/tail/version.PlatformName={{.Arch}} + +archives: + - + name_template: '{{ .ProjectName }}_{{ .Tag }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}' brews: - tap: @@ -34,47 +45,6 @@ brews: homepage: "https://github.com/boz/kail" description: "kubernetes tail - pod log viewer" -krews: - - name: tail - goarm: 6 - goamd64: v2 - index: - owner: boz - name: krew-index - branch: master - commit_author: - name: boz - email: adam.boz@gmail.com - homepage: "https://github.com/boz/kail" - description: |- - Kail https://github.com/boz/kail - "Just show me the logs" - - Stream logs from all matched containers of all matched pods. Match pods by service, - replicaset, deployment, and others. Adjusts to a changing cluster - pods are - added and removed from logging as they fall in or out of the selection. - - Documentation: - See https://github.com/boz/kail or - $ kubectl tail --help - - Usage: - - # match all pods - $ kubectl tail - - # match pods in the 'frontend' namespace - $ kubectl tail --ns staging - - # match pods belonging to a replicaset named 'workers' in any namespace. - $ kubectl tail --rs workers - - # match pods belonging to the replicaset named 'workers' only in the 'staging' namespace - $ kubectl tail --rs staging/workers - - # match pods belonging to both the service "frontend" and the deployment "webapp" - $ kubectl tail --svc frontend --deploy webapp - short_description: "Stream logs from multiple pods and containers using simple, dynamic source selection." - checksum: name_template: "checksums.txt" snapshot: diff --git a/.krew/tail.yaml b/.krew/tail.yaml new file mode 100644 index 0000000..0f818b7 --- /dev/null +++ b/.krew/tail.yaml @@ -0,0 +1,82 @@ +apiVersion: krew.googlecontainertools.github.com/v1alpha2 +kind: Plugin +metadata: + name: tail +spec: + version: "{{ .TagName }}" + platforms: + - {{addURIAndSha "https://github.com/boz/kail/releases/download/{{ .TagName }}/kail_{{ .TagName }}_darwin_arm64.tar.gz" .TagName }} + selector: + matchLabels: + os: darwin + arch: arm64 + bin: kail + files: + - from: "kail" + to: "." + - from: LICENSE.txt + to: . + - {{addURIAndSha "https://github.com/boz/kail/releases/download/{{ .TagName }}/kail_{{ .TagName }}_darwin_amd64v2.tar.gz" .TagName }} + selector: + matchLabels: + os: darwin + arch: amd64 + bin: kail + files: + - from: "kail" + to: "." + - from: LICENSE.txt + to: . + - {{addURIAndSha "https://github.com/boz/kail/releases/download/{{ .TagName }}/kail_{{ .TagName }}_linux_arm64.tar.gz" .TagName }} + selector: + matchLabels: + os: linux + arch: arm64 + bin: kail + files: + - from: "kail" + to: "." + - from: LICENSE.txt + to: . + - {{addURIAndSha "https://github.com/boz/kail/releases/download/{{ .TagName }}/kail_{{ .TagName }}_linux_amd64v2.tar.gz" .TagName }} + selector: + matchLabels: + os: linux + arch: amd64 + bin: kail + files: + - from: "kail" + to: "." + - from: LICENSE.txt + to: . + homepage: https://github.com/boz/kail + shortDescription: Stream logs from multiple pods and containers using simple, dynamic source selection. + description: |- + Kail https://github.com/boz/kail - "Just show me the logs" + + Stream logs from all matched containers of all matched pods. Match pods by service, + replicaset, deployment, and others. Adjusts to a changing cluster - pods are + added and removed from logging as they fall in or out of the selection. + + Documentation: + + See https://github.com/boz/kail or + + $ kubectl tail --help + + Usage: + + # match all pods + $ kubectl tail + + # match pods in the 'frontend' namespace + $ kubectl tail --ns staging + + # match pods belonging to a replicaset named 'workers' in any namespace. + $ kubectl tail --rs workers + + # match pods belonging to the replicaset named 'workers' only in the 'staging' namespace + $ kubectl tail --rs staging/workers + + # match pods belonging to both the service "frontend" and the deployment "webapp" + $ kubectl tail --svc frontend --deploy webapp diff --git a/go.mod b/go.mod index 23abac8..5963b3a 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( github.com/rs/zerolog v1.15.0 github.com/sirupsen/logrus v1.9.0 github.com/stretchr/testify v1.8.1 - github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 gopkg.in/alecthomas/kingpin.v2 v2.2.6 k8s.io/api v0.26.0 k8s.io/apimachinery v0.26.0 diff --git a/go.sum b/go.sum index e54b75e..aca4542 100644 --- a/go.sum +++ b/go.sum @@ -206,8 +206,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= -github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=