Skip to content

Commit e75100f

Browse files
committed
chore: release v1.0.20260922
1 parent a751828 commit e75100f

5 files changed

Lines changed: 269 additions & 70 deletions

File tree

‎.github/workflows/docker-image.yml‎

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
name: 'Docker 镜像构建'
2+
3+
# 触发时机:
4+
# 1. push 到 main 或开 PR:构建镜像并上传工件,只做自检,不发布 Release;
5+
# 2. 推送 v* 标签,或用户在 GitHub 上「发布」一个版本:额外把镜像 tar 包挂到那个 Release 上。
6+
# 说明:release.yml 的 Release 流水线也会构建同名单平台镜像,两条流水线产出同名产物,重复上传只是覆盖。
27
on:
38
workflow_dispatch:
49
pull_request:
@@ -7,31 +12,76 @@ on:
712
- main
813
tags:
914
- 'v*'
15+
release:
16+
types: [published, released]
17+
1018
permissions:
11-
contents: read
19+
contents: write
20+
21+
# PR 与 push 可能同时触发,串行执行避免并发争抢同一工件名
22+
concurrency:
23+
group: 'docker-${{ github.workflow }}-${{ github.ref }}'
24+
cancel-in-progress: false
25+
26+
env:
27+
BIN_NAME: simple-web-shell
1228

1329
jobs:
1430
docker-build:
31+
name: '构建镜像 ${{ matrix.arch }}'
1532
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
include:
37+
- { arch: amd64, platform: 'linux/amd64' }
38+
- { arch: arm64, platform: 'linux/arm64' }
1639
steps:
17-
- uses: actions/checkout@v4
18-
- name: 'Go 鍗曞厓娴嬭瘯'
19-
uses: actions/setup-go@v5
20-
with:
21-
go-version: '1.25'
22-
- name: '杩愯娴嬭瘯'
23-
run: go test ./...
24-
- name: '静态检查 go vet'
25-
run: go vet ./...
26-
- name: '构建 Docker 镜像'
27-
run: |
28-
docker build -t simple-web-shell .
29-
- name: '导出并上传镜像工件'
30-
run: |
31-
docker save simple-web-shell | gzip > simple-web-shell-image.tar.gz
32-
- uses: actions/upload-artifact@v4
33-
with:
34-
name: 'simple-web-shell-docker-image-${{ github.ref_name }}'
35-
path: 'simple-web-shell-image.tar.gz'
36-
if-no-files-found: 'warn'
37-
retention-days: 14
40+
- name: '检出代码'
41+
uses: actions/checkout@v4
42+
43+
- name: 'Go 单元测试'
44+
uses: actions/setup-go@v5
45+
with:
46+
go-version: '1.25'
47+
48+
- name: '运行测试'
49+
run: go test ./...
50+
51+
- name: '静态检查 go vet'
52+
run: go vet ./...
53+
54+
- name: '启用 QEMU(arm64 镜像构建)'
55+
uses: docker/setup-qemu-action@v3
56+
57+
- name: '启用 Buildx'
58+
uses: docker/setup-buildx-action@v3
59+
60+
- name: '构建镜像并导出 tar 包'
61+
run: |
62+
set -euo pipefail
63+
out="$BIN_NAME-image-${{ matrix.arch }}.tar"
64+
# docker 导出器只接受单平台结果,所以按矩阵逐个架构导出,而不是一次构建多平台
65+
docker buildx build \
66+
--platform ${{ matrix.platform }} \
67+
--tag "$BIN_NAME:${{ matrix.arch }}" \
68+
--output "type=docker,dest=$out" \
69+
.
70+
ls -lh "$out"
71+
gzip -9 -f "$out"
72+
73+
- name: '上传镜像工件'
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: 'docker-image-${{ matrix.arch }}'
77+
path: '${{ env.BIN_NAME }}-image-${{ matrix.arch }}.tar.gz'
78+
if-no-files-found: 'error'
79+
retention-days: 7
80+
81+
- name: '上传镜像包到 Release'
82+
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/')
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ github.event.release.tag_name || github.ref_name }}
86+
files: '${{ env.BIN_NAME }}-image-${{ matrix.arch }}.tar.gz'
87+
fail_on_unmatched_files: false

‎.github/workflows/release.yml‎

Lines changed: 193 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,74 @@
1-
name: '跨平台 Release 打包'
1+
name: 'Release 打包'
2+
3+
# 触发时机:
4+
# 1. 用户在 GitHub 上「发布」一个版本(Release published / 从草稿发布)——主路径;
5+
# 2. 推送 v* 标签;
6+
# 3. 手动触发(需指定标签)。
7+
# 产物:六平台可执行文件 tar/zip + linux/amd64、linux/arm64 两个 Docker 镜像 tar 包。
28
on:
39
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: '要发布/上传的版本标签,例如 v1.0.20260920'
13+
required: false
14+
type: string
415
push:
516
tags:
617
- 'v*'
18+
release:
19+
types: [published, released]
720

821
permissions:
922
contents: write
1023

24+
# 同一标签可能同时被「推标签」和「发布 Release」触发,串行执行避免重复上传
25+
concurrency:
26+
group: 'release-${{ github.workflow }}-${{ github.ref }}'
27+
cancel-in-progress: false
28+
29+
env:
30+
BIN_NAME: simple-web-shell
31+
1132
jobs:
33+
meta:
34+
name: '解析发布标签'
35+
runs-on: ubuntu-latest
36+
outputs:
37+
tag: ${{ steps.vars.outputs.tag }}
38+
publish: ${{ steps.vars.outputs.publish }}
39+
steps:
40+
- name: '检出代码'
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ inputs.tag || github.event.release.tag_name || github.ref }}
44+
45+
- id: vars
46+
name: '解析标签并校验版本号'
47+
shell: bash
48+
run: |
49+
set -euo pipefail
50+
tag='${{ inputs.tag || github.event.release.tag_name || github.ref_name }}'
51+
publish=false
52+
case "$tag" in
53+
v*) publish=true ;;
54+
*) publish=false ;;
55+
esac
56+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
57+
echo "publish=$publish" >> "$GITHUB_OUTPUT"
58+
echo "发布标签: ${tag:-<未指定>}"
59+
echo "是否发布 Release: $publish"
60+
if [ "$publish" = "true" ]; then
61+
version="$(grep -oP '(?<=version := ")[^"]+' main.go | head -n1)"
62+
echo "源码版本号: ${version}"
63+
if [ "$tag" != "v${version}" ]; then
64+
echo "::error::发布标签 ${tag} 与源码版本号 v${version} 不一致,请先把 main.go 里的版本号改成 ${tag#v} 再发布。"
65+
exit 1
66+
fi
67+
fi
68+
1269
build:
13-
name: '构建 ${{ matrix.target }}'
70+
name: '编译打包 ${{ matrix.target }}'
71+
needs: meta
1472
runs-on: ubuntu-latest
1573
strategy:
1674
fail-fast: false
@@ -23,50 +81,141 @@ jobs:
2381
- { target: windows-amd64, goos: windows, goarch: amd64, ext: .exe }
2482
- { target: windows-arm64, goos: windows, goarch: arm64, ext: .exe }
2583
steps:
26-
- uses: actions/checkout@v4
27-
- uses: actions/setup-go@v5
28-
with:
29-
go-version: '1.25'
30-
- name: '编译 ${{ matrix.target }}'
31-
run: |
32-
mkdir -p dist
33-
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
34-
go build -trimpath -ldflags="-s -w" -o dist/simple-web-shell${{ matrix.ext }} .
35-
- name: '打包'
36-
run: |
37-
cd dist
38-
if [ "${{ matrix.goos }}" = "windows" ]; then
39-
zip -qr ../simple-web-shell-${{ matrix.target }}.zip simple-web-shell.exe
40-
else
41-
tar czf ../simple-web-shell-${{ matrix.target }}.tar.gz simple-web-shell
42-
fi
43-
- uses: actions/upload-artifact@v4
44-
with:
45-
name: 'simple-web-shell-${{ matrix.target }}'
46-
path: '${{ github.workspace }}/simple-web-shell-${{ matrix.target }}.*'
47-
if-no-files-found: 'error'
48-
retention-days: 1
84+
- name: '检出代码'
85+
uses: actions/checkout@v4
86+
with:
87+
ref: ${{ inputs.tag || github.event.release.tag_name || github.ref }}
88+
89+
- name: '安装 Go'
90+
uses: actions/setup-go@v5
91+
with:
92+
go-version: '1.25'
93+
94+
- name: '单元测试'
95+
run: go test ./...
96+
97+
- name: '静态检查 go vet'
98+
run: go vet ./...
99+
100+
- name: '编译 ${{ matrix.target }}'
101+
run: |
102+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
103+
go build -trimpath -ldflags="-s -w" \
104+
-o "$BIN_NAME${{ matrix.ext }}" .
105+
106+
- name: '打包 tar/zip'
107+
run: |
108+
set -euo pipefail
109+
target='${{ matrix.target }}'
110+
bin="$BIN_NAME${{ matrix.ext }}"
111+
stage="$BIN_NAME-$target"
112+
rm -rf "$stage" && mkdir -p "$stage"
113+
cp "$bin" "$stage/"
114+
for doc in README.md LICENSE; do
115+
[ -f "$doc" ] && cp "$doc" "$stage/"
116+
done
117+
files=()
118+
for f in "$stage"/*; do files+=("${f##*/}"); done
119+
if [ '${{ matrix.goos }}' = 'windows' ]; then
120+
( cd "$stage" && zip -qr "../$stage.zip" "${files[@]}" )
121+
else
122+
tar czf "$stage.tar.gz" -C "$stage" "${files[@]}"
123+
fi
124+
ls -l "$stage".tar.gz "$stage".zip 2>/dev/null || true
125+
126+
- name: '上传打包工件'
127+
uses: actions/upload-artifact@v4
128+
with:
129+
name: 'bin-${{ matrix.target }}'
130+
path: 'simple-web-shell-${{ matrix.target }}.*'
131+
if-no-files-found: 'error'
132+
retention-days: 7
133+
134+
docker:
135+
name: '构建 Docker 镜像 ${{ matrix.arch }}'
136+
needs: meta
137+
runs-on: ubuntu-latest
138+
strategy:
139+
fail-fast: false
140+
matrix:
141+
include:
142+
- { arch: amd64, platform: 'linux/amd64' }
143+
- { arch: arm64, platform: 'linux/arm64' }
144+
steps:
145+
- name: '检出代码'
146+
uses: actions/checkout@v4
147+
with:
148+
ref: ${{ inputs.tag || github.event.release.tag_name || github.ref }}
149+
150+
- name: '启用 QEMU(arm64 镜像构建)'
151+
uses: docker/setup-qemu-action@v3
152+
153+
- name: '启用 Buildx'
154+
uses: docker/setup-buildx-action@v3
155+
156+
- name: '构建镜像并导出 tar 包'
157+
run: |
158+
set -euo pipefail
159+
out="$BIN_NAME-image-${{ matrix.arch }}.tar"
160+
docker buildx build \
161+
--platform ${{ matrix.platform }} \
162+
--tag "$BIN_NAME:${{ matrix.arch }}" \
163+
--output "type=docker,dest=$out" \
164+
.
165+
gzip -9 -f "$out"
166+
167+
- name: '上传镜像工件'
168+
uses: actions/upload-artifact@v4
169+
with:
170+
name: 'docker-image-${{ matrix.arch }}'
171+
path: 'simple-web-shell-image-${{ matrix.arch }}.tar.gz'
172+
if-no-files-found: 'error'
173+
retention-days: 7
49174

50175
release:
51176
name: '发布 GitHub Release'
52-
needs: build
177+
needs: [build, docker]
178+
if: needs.meta.outputs.publish == 'true'
53179
runs-on: ubuntu-latest
54180
steps:
55-
- uses: actions/download-artifact@v4
56-
with:
57-
path: artifacts
58-
merge-multiple: true
59-
- name: '整理产物'
60-
run: |
61-
mkdir -p release
62-
find artifacts -type f | while read -r f; do
63-
case "$f" in
64-
*.tar.gz|*.zip) cp "$f" release/ ;;
65-
esac
66-
done
67-
- name: '上传到 Release'
68-
uses: softprops/action-gh-release@v2
69-
with:
70-
files: 'release/*'
71-
generate_release_notes: true
72-
fail_on_unmatched_files: false
181+
- name: '汇总全部产物'
182+
uses: actions/download-artifact@v4
183+
with:
184+
pattern: '*'
185+
path: artifacts
186+
merge-multiple: true
187+
188+
- name: '生成 SHA256/MD5/SHA1 校验文件'
189+
run: |
190+
set -euo pipefail
191+
cd artifacts
192+
find . -type f \
193+
! -name 'SHA256SUMS.txt' \
194+
! -name 'checksums-md5.txt' \
195+
! -name 'checksums-sha1.txt' -print0 \
196+
| sort -z | xargs -0 -r sha256sum > SHA256SUMS.txt
197+
find . -type f \
198+
! -name 'SHA256SUMS.txt' \
199+
! -name 'checksums-md5.txt' \
200+
! -name 'checksums-sha1.txt' -print0 \
201+
| sort -z | xargs -0 -r md5sum > checksums-md5.txt
202+
find . -type f \
203+
! -name 'SHA256SUMS.txt' \
204+
! -name 'checksums-md5.txt' \
205+
! -name 'checksums-sha1.txt' -print0 \
206+
| sort -z | xargs -0 -r sha1sum > checksums-sha1.txt
207+
cat SHA256SUMS.txt checksums-md5.txt checksums-sha1.txt
208+
209+
- name: '上传到 Release'
210+
uses: softprops/action-gh-release@v2
211+
with:
212+
tag_name: ${{ needs.meta.outputs.tag }}
213+
name: ${{ needs.meta.outputs.tag }}
214+
generate_release_notes: true
215+
files: |
216+
artifacts/*.tar.gz
217+
artifacts/*.zip
218+
artifacts/SHA256SUMS.txt
219+
artifacts/checksums-md5.txt
220+
artifacts/checksums-sha1.txt
221+
fail_on_unmatched_files: true

‎main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func init() {
3232
}
3333

3434
func main() {
35-
version := "1.0.20260901" // 当前系统的版本
35+
version := "1.0.20260922" // 当前系统的版本
3636
flag.Parse()
3737

3838
// 检查必需参数

‎pages/index.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func GetWebShellHTML() string {
1212
<head>
1313
<meta charset="UTF-8">
1414
<meta name="viewport" content="width=device-width, initial-scale=1.0">
15-
<title>SimpleWebShell 1.0.20260901</title>
15+
<title>SimpleWebShell 1.0.20260922</title>
1616
<style>
1717
body {
1818
font-family: 'Courier New', monospace;
@@ -49,7 +49,7 @@ func GetWebShellHTML() string {
4949
</head>
5050
<body>
5151
<div class="container">
52-
<h1>SimpleWebShell 1.0.20260901 By FasterEdge</h1>
52+
<h1>SimpleWebShell 1.0.20260922 By FasterEdge</h1>
5353
5454
<div class="session-section">
5555
<div class="input-group no-gap" style="align-items:center;">

0 commit comments

Comments
 (0)