Skip to content

Commit 2ba1bcb

Browse files
author
mcgrady.sun
committed
feat: 发布 v0.2.0 初始版本,支持交互式模式和配置文件
核心功能: - 跨平台端口进程管理(Linux/macOS/Windows) - 交互式 TUI 模式(多选、排序、滚动) - 配置文件支持(YAML 格式,预设端口组) - init 命令:一键初始化配置文件 - preset 命令:使用预设端口组 - --dev 快捷命令:清理常用开发端口(3000/8080/5173/5000/4200) - list 命令:列出所有占用的端口 - 端口号自动排序(从小到大) CI/CD: - GitHub Actions 自动构建和发布 - GoReleaser 跨平台编译配置 - 集成测试流程 文档: - 中文 README 作为默认文档 - 英文 README.en.md - 完整的使用说明和示例
0 parents  commit 2ba1bcb

22 files changed

Lines changed: 2953 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
# 第一步:跨平台集成测试
13+
integration-test:
14+
name: Integration Test on ${{ matrix.os }}
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: true
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
go-version: ['1.25']
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: ${{ matrix.go-version }}
30+
31+
- name: Cache Go modules
32+
uses: actions/cache@v4
33+
with:
34+
path: |
35+
~/go/pkg/mod
36+
~/.cache/go-build
37+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
38+
restore-keys: |
39+
${{ runner.os }}-go-
40+
41+
- name: Download dependencies
42+
run: go mod download
43+
44+
- name: Run unit tests
45+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
46+
47+
- name: Build binary
48+
run: make build
49+
50+
- name: Integration Test - Version
51+
shell: bash
52+
run: |
53+
if [[ "${{ runner.os }}" == "Windows" ]]; then
54+
./killport.exe --version
55+
else
56+
./killport --version
57+
fi
58+
59+
- name: Integration Test - Help
60+
shell: bash
61+
run: |
62+
if [[ "${{ runner.os }}" == "Windows" ]]; then
63+
./killport.exe --help
64+
else
65+
./killport --help
66+
fi
67+
68+
- name: Integration Test - List (dry run)
69+
shell: bash
70+
run: |
71+
if [[ "${{ runner.os }}" == "Windows" ]]; then
72+
./killport.exe list || echo "List command executed"
73+
else
74+
./killport list || echo "List command executed"
75+
fi
76+
77+
- name: Integration Test - Init config
78+
shell: bash
79+
run: |
80+
if [[ "${{ runner.os }}" == "Windows" ]]; then
81+
./killport.exe init --yes
82+
else
83+
./killport init --yes
84+
fi
85+
86+
- name: Integration Test - Verify config created
87+
shell: bash
88+
run: |
89+
if [[ "${{ runner.os }}" == "Windows" ]]; then
90+
test -f "$HOME/.killport.yaml" && echo "✅ Config file created" || echo "❌ Config file not found"
91+
else
92+
test -f "$HOME/.killport.yaml" && echo "✅ Config file created" || echo "❌ Config file not found"
93+
fi
94+
95+
- name: Upload coverage to Codecov (Ubuntu only)
96+
if: matrix.os == 'ubuntu-latest'
97+
uses: codecov/codecov-action@v4
98+
with:
99+
file: ./coverage.txt
100+
flags: unittests
101+
name: codecov-umbrella
102+
103+
# 第二步:构建和发布(依赖测试通过)
104+
release:
105+
name: Build and Release
106+
needs: integration-test
107+
runs-on: ubuntu-latest
108+
outputs:
109+
version: ${{ steps.get_version.outputs.version }}
110+
111+
steps:
112+
- name: Checkout code
113+
uses: actions/checkout@v4
114+
with:
115+
fetch-depth: 0
116+
117+
- name: Set up Go
118+
uses: actions/setup-go@v5
119+
with:
120+
go-version: '1.25'
121+
122+
- name: Get version
123+
id: get_version
124+
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
125+
126+
- name: Run GoReleaser
127+
uses: goreleaser/goreleaser-action@v5
128+
with:
129+
distribution: goreleaser
130+
version: latest
131+
args: release --clean
132+
env:
133+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134+
135+
# 第三步:发布到包管理器(暂时禁用)
136+
# publish-homebrew:
137+
# name: Publish to Homebrew
138+
# needs: release
139+
# runs-on: ubuntu-latest
140+
# if: github.repository == 'TNT-Likely/killport'
141+
#
142+
# steps:
143+
# - name: Checkout code
144+
# uses: actions/checkout@v4
145+
#
146+
# - name: Update Homebrew tap
147+
# env:
148+
# HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
149+
# run: |
150+
# if [[ -z "$HOMEBREW_TAP_TOKEN" ]]; then
151+
# echo "⚠️ HOMEBREW_TAP_GITHUB_TOKEN not set, skipping Homebrew publish"
152+
# exit 0
153+
# fi
154+
#
155+
# echo "✅ Homebrew Formula will be updated by GoReleaser"
156+
# echo "📦 Version: ${{ needs.release.outputs.version }}"
157+
158+
# publish-scoop:
159+
# name: Publish to Scoop
160+
# needs: release
161+
# runs-on: ubuntu-latest
162+
# if: github.repository == 'TNT-Likely/killport'
163+
#
164+
# steps:
165+
# - name: Checkout code
166+
# uses: actions/checkout@v4
167+
#
168+
# - name: Update Scoop bucket
169+
# env:
170+
# SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_GITHUB_TOKEN }}
171+
# run: |
172+
# if [[ -z "$SCOOP_BUCKET_TOKEN" ]]; then
173+
# echo "⚠️ SCOOP_BUCKET_GITHUB_TOKEN not set, skipping Scoop publish"
174+
# exit 0
175+
# fi
176+
#
177+
# VERSION="${{ needs.release.outputs.version }}"
178+
# echo "📦 Preparing Scoop manifest for $VERSION"
179+
# echo "ℹ️ Manual step: Update scoop-bucket repository with new manifest"
180+
181+
# 第三步:发布通知
182+
notify:
183+
name: Notify Release
184+
needs: [release]
185+
runs-on: ubuntu-latest
186+
if: always()
187+
188+
steps:
189+
- name: Release Summary
190+
run: |
191+
echo "🎉 Release ${{ needs.release.outputs.version }} completed!"
192+
echo ""
193+
echo "✅ Integration tests: Passed"
194+
echo "✅ Build and release: Completed"
195+
echo "📦 Artifacts published to GitHub Releases"
196+
echo ""
197+
echo "📍 Download: https://github.com/${{ github.repository }}/releases/tag/${{ needs.release.outputs.version }}"

.gitignore

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool
12+
*.out
13+
*.prof
14+
15+
# Go workspace file
16+
go.work
17+
go.work.sum
18+
19+
# Build artifacts
20+
/killport
21+
/dist/
22+
*.tar.gz
23+
*.zip
24+
25+
# IDEs
26+
.idea/
27+
.vscode/
28+
*.swp
29+
*.swo
30+
*~
31+
32+
# OS
33+
.DS_Store
34+
Thumbs.db
35+
.AppleDouble
36+
.LSOverride
37+
38+
# Temporary files
39+
tmp/
40+
temp/
41+
*.log
42+
43+
# Development
44+
coverage.txt
45+
coverage.html
46+
47+
# Release files
48+
release/

.golangci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# golangci-lint 配置文件
2+
# 文档: https://golangci-lint.run/usage/configuration/
3+
4+
run:
5+
timeout: 5m
6+
tests: true
7+
skip-dirs:
8+
- tmp
9+
- dist
10+
skip-files:
11+
- ".*_test.go"
12+
13+
linters:
14+
enable:
15+
- errcheck
16+
- gosimple
17+
- govet
18+
- ineffassign
19+
- staticcheck
20+
- typecheck
21+
- unused
22+
- gofmt
23+
- goimports
24+
25+
linters-settings:
26+
errcheck:
27+
check-blank: true
28+
check-type-assertions: true
29+
30+
issues:
31+
exclude-rules:
32+
# Exclude some linters from running on tests files
33+
- path: _test\.go
34+
linters:
35+
- errcheck

0 commit comments

Comments
 (0)