Skip to content

Commit 10afdac

Browse files
authored
Merge pull request #16 from chez-shanpu/prepare-release
Prepare for releases
2 parents f04467e + bc80d2f commit 10afdac

File tree

6 files changed

+182
-2
lines changed

6 files changed

+182
-2
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
env:
15+
GO_VERSION: '1.24'
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ env.GO_VERSION }}
26+
check-latest: true
27+
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@v6
30+
with:
31+
distribution: goreleaser
32+
version: "~> v2"
33+
args: release --clean
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- id: kubectl-mft
9+
binary: kubectl-mft
10+
env:
11+
- CGO_ENABLED=0
12+
goos:
13+
- linux
14+
- windows
15+
- darwin
16+
goarch:
17+
- amd64
18+
- arm64
19+
ldflags:
20+
- -s -w
21+
- -X github.com/chez-shanpu/kubectl-mft/cmd.version={{.Version}}
22+
- -X github.com/chez-shanpu/kubectl-mft/cmd.commit={{.ShortCommit}}
23+
mod_timestamp: "{{ .CommitTimestamp }}"
24+
25+
archives:
26+
- id: kubectl-mft
27+
formats: tar.gz
28+
# use zip for windows archives
29+
format_overrides:
30+
- goos: windows
31+
formats: zip
32+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
33+
files:
34+
- README.md
35+
- LICENSE
36+
37+
changelog:
38+
use: github
39+
filters:
40+
exclude:
41+
- "^docs:"
42+
- "^test:"
43+
- "^ci:"
44+
- Merge pull request
45+
- Merge branch
46+
groups:
47+
- title: Features
48+
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
49+
order: 0
50+
- title: "Bug Fixes"
51+
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
52+
order: 1
53+
- title: Others
54+
order: 999
55+
56+
checksum:
57+
name_template: "checksums.txt"
58+
algorithm: sha256
59+
60+
release:
61+
github:
62+
owner: chez-shanpu
63+
name: kubectl-mft
64+
draft: false
65+
prerelease: auto
66+
mode: append
67+
header: |
68+
## kubectl-mft {{ .Tag }}
69+
70+
Release of kubectl-mft version {{ .Tag }}.
71+
72+
footer: |
73+
## Installation
74+
75+
### Download Binary
76+
77+
**Linux / macOS**
78+
79+
```bash
80+
# Download and extract (replace OS and ARCH as needed)
81+
curl -L https://github.com/chez-shanpu/kubectl-mft/releases/download/{{ .Tag }}/kubectl-mft_{{ .Tag }}_OS_ARCH.tar.gz | tar xz
82+
83+
# Move to a directory in your PATH
84+
sudo mv kubectl-mft /usr/local/bin/
85+
86+
# Verify installation
87+
kubectl mft version
88+
```
89+
90+
**Windows**
91+
92+
Download the `.zip` file for your architecture from the assets above, extract it, and add the binary to your PATH.
93+
94+
### Using Go
95+
96+
```bash
97+
go install github.com/chez-shanpu/kubectl-mft@{{ .Tag }}
98+
```
99+
100+
---
101+
102+
**Full Changelog**: https://github.com/chez-shanpu/kubectl-mft/compare/{{ .PreviousTag }}...{{ .Tag }}

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,19 @@ test-e2e:
4040

4141
.PHONY: build
4242
build:
43-
$(GO) build -o bin/ .
43+
$(GO) build -ldflags "-X github.com/chez-shanpu/kubectl-mft/cmd.version=dev -X github.com/chez-shanpu/kubectl-mft/cmd.commit=$$(git rev-parse --short HEAD 2>/dev/null || echo 'none')" -o bin/ .
4444

4545
.PHONY: clean
4646
clean:
4747
-$(GO) clean
4848
-rm $(RM_OPTS) $(BIN_DIR)
4949

50+
.PHONY: check-goreleaser
51+
check-goreleaser:
52+
goreleaser check
53+
5054
.PHONY: check
51-
check: vet check-diff test
55+
check: vet check-diff test check-goreleaser
5256

5357
.PHONY: check-all
5458
check-all: check test-e2e

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@ kubectl mft dump -t localhost:5000/myapp/config:v1.0.0 | kubectl apply -f -
5555

5656
## Installation
5757

58+
### Download Binary from GitHub Releases
59+
60+
Download the latest release for your platform from [GitHub Releases](https://github.com/chez-shanpu/kubectl-mft/releases).
61+
62+
**Linux / macOS**
63+
64+
```bash
65+
# Download and extract (replace VERSION, OS, and ARCH as needed)
66+
curl -L https://github.com/chez-shanpu/kubectl-mft/releases/download/VERSION/kubectl-mft_VERSION_OS_ARCH.tar.gz | tar xz
67+
68+
# Move to a directory in your PATH
69+
sudo mv kubectl-mft /usr/local/bin/
70+
71+
# Verify installation
72+
kubectl mft version
73+
```
74+
75+
**Windows**
76+
77+
Download the `.zip` file for your architecture from the releases page, extract it, and add the binary to your PATH.
78+
5879
### Using Go
5980

6081
```bash
@@ -120,7 +141,11 @@ kubectl mft list -o yaml
120141
**Get file path to manifest blob**
121142

122143
```bash
144+
# Get the file path
123145
kubectl mft path -t localhost:5000/myapp:v1.0.0
146+
147+
# Use with kubectl debug --custom
148+
kubectl debug mypod -it --image busyboz --custom=$(kubectl mft path -t localhost:5000/debug-container)
124149
```
125150

126151
**Delete a manifest**

aqua.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ registries:
1313
packages:
1414
- name: dominikh/go-tools/staticcheck@2025.1.1
1515
- name: golang/tools/goimports@v0.38.0
16+
- name: goreleaser/goreleaser@v2.12.7

cmd/root.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
package cmd
55

66
import (
7+
"fmt"
78
"os"
89

910
"github.com/spf13/cobra"
1011
)
1112

13+
var (
14+
// Version information. These are set via ldflags during build.
15+
version = "dev"
16+
commit = "none"
17+
)
18+
1219
const (
1320
TagFlag = "tag"
1421
TagShortFlag = "t"
@@ -28,6 +35,12 @@ var rootCmd = &cobra.Command{
2835
Use: "kubectl-mft",
2936
Short: "A kubectl plugin for managing Kubernetes manifests",
3037
SilenceUsage: true,
38+
Version: version,
39+
}
40+
41+
func init() {
42+
// Customize version output template
43+
rootCmd.SetVersionTemplate(fmt.Sprintf("kubectl-mft version %s (commit: %s)\n", version, commit))
3144
}
3245

3346
// Execute adds all child commands to the root command and sets flags appropriately.

0 commit comments

Comments
 (0)