Skip to content

Commit 5362c0d

Browse files
author
FasterEdge
committed
chore(ci): merge main into dependabot/docker/alpine-3.24
Bring the PR branch up to date with main so PR CI runs the fixed workflows.
2 parents 78a17e6 + 0ab8eb7 commit 5362c0d

3 files changed

Lines changed: 103 additions & 6 deletions

File tree

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,49 @@
11
name: 'Docker 镜像构建'
22
on:
33
workflow_dispatch:
4+
pull_request:
45
push:
6+
branches:
7+
- main
58
tags:
69
- 'v*' # 打 v0.1.0 等标签时自动构建并产出镜像
10+
release:
11+
types: [published, released]
712
permissions:
8-
contents: read
13+
contents: write
914

1015
jobs:
1116
docker-build:
1217
runs-on: ubuntu-latest
1318
steps:
1419
- uses: actions/checkout@v4
15-
- name: 'Go 鍗曞厓娴嬭瘯'
20+
- name: 'Go 单元测试'
1621
uses: actions/setup-go@v5
1722
with:
18-
go-version: '1.25'
19-
- name: '杩愯娴嬭瘯'
23+
go-version: '1.26'
24+
- name: '运行测试'
2025
run: go test ./...
2126
- name: '构建 Docker 镜像'
2227
run: |
2328
docker build -t simplewebshell-remoteupdate .
2429
- name: '导出并上传镜像工件'
2530
run: |
2631
docker save simplewebshell-remoteupdate | gzip > simplewebshell-remoteupdate-image.tar.gz
32+
# PR 的 ref_name 形如 15/merge,dependabot 分支名也含斜杠,
33+
# 而 upload-artifact 的工件名不允许出现 /,这里统一替换为连字符。
34+
- name: '计算工件名'
35+
shell: bash
36+
run: echo "ARTIFACT_NAME=simplewebshell-remoteupdate-docker-image-${GITHUB_REF_NAME//\//-}" >> "$GITHUB_ENV"
2737
- uses: actions/upload-artifact@v4
2838
with:
29-
name: 'simplewebshell-remoteupdate-docker-image-${{ github.ref_name }}'
39+
name: ${{ env.ARTIFACT_NAME }}
3040
path: 'simplewebshell-remoteupdate-image.tar.gz'
3141
if-no-files-found: 'warn'
3242
retention-days: 14
43+
- name: '上传镜像包到 Release'
44+
if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
45+
uses: softprops/action-gh-release@v2
46+
with:
47+
tag_name: ${{ github.event.release.tag_name || github.ref_name }}
48+
files: 'simplewebshell-remoteupdate-image.tar.gz'
49+
fail_on_unmatched_files: false

‎.github/workflows/release.yml‎

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: 'Release 打包'
2+
on:
3+
workflow_dispatch:
4+
push:
5+
tags:
6+
- 'v*'
7+
release:
8+
types: [published, released]
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
build:
15+
name: '构建 ${{ matrix.target }}'
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
include:
21+
- { target: linux-amd64, goos: linux, goarch: amd64, ext: '' }
22+
- { target: linux-arm64, goos: linux, goarch: arm64, ext: '' }
23+
- { target: darwin-amd64, goos: darwin, goarch: amd64, ext: '' }
24+
- { target: darwin-arm64, goos: darwin, goarch: arm64, ext: '' }
25+
- { target: windows-amd64, goos: windows, goarch: amd64, ext: .exe }
26+
- { target: windows-arm64, goos: windows, goarch: arm64, ext: .exe }
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-go@v5
30+
with:
31+
go-version: '1.26'
32+
- name: '编译 ${{ matrix.target }}'
33+
run: |
34+
mkdir -p dist
35+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
36+
go build -trimpath -ldflags="-s -w" -o dist/simplewebshell-remoteupdate${{ matrix.ext }} .
37+
- name: '打包'
38+
run: |
39+
cd dist
40+
if [ "${{ matrix.goos }}" = "windows" ]; then
41+
zip -qr ../simplewebshell-remoteupdate-${{ matrix.target }}.zip simplewebshell-remoteupdate.exe
42+
else
43+
tar czf ../simplewebshell-remoteupdate-${{ matrix.target }}.tar.gz simplewebshell-remoteupdate
44+
fi
45+
- uses: actions/upload-artifact@v4
46+
with:
47+
name: 'simplewebshell-remoteupdate-${{ matrix.target }}'
48+
path: '${{ github.workspace }}/simplewebshell-remoteupdate-${{ matrix.target }}.*'
49+
if-no-files-found: 'error'
50+
retention-days: 1
51+
52+
release:
53+
name: '发布 GitHub Release'
54+
needs: build
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: actions/download-artifact@v4
58+
with:
59+
path: artifacts
60+
merge-multiple: true
61+
- name: '整理产物'
62+
run: |
63+
mkdir -p release
64+
find artifacts -type f \( -name '*.tar.gz' -o -name '*.zip' \) -exec cp {} release/ \;
65+
- name: '生成 MD5/SHA1 校验文件'
66+
run: |
67+
set -euo pipefail
68+
cd release
69+
find . -type f ! -name 'checksums-md5.txt' ! -name 'checksums-sha1.txt' -print0 \
70+
| sort -z | xargs -0 -r md5sum > checksums-md5.txt
71+
find . -type f ! -name 'checksums-md5.txt' ! -name 'checksums-sha1.txt' -print0 \
72+
| sort -z | xargs -0 -r sha1sum > checksums-sha1.txt
73+
- name: '上传到 Release'
74+
if: github.event_name != 'workflow_dispatch' || github.event.inputs.tag != ''
75+
uses: softprops/action-gh-release@v2
76+
with:
77+
tag_name: ${{ github.event.inputs.tag || github.event.release.tag_name || github.ref_name }}
78+
files: 'release/*'
79+
generate_release_notes: true
80+
fail_on_unmatched_files: false

‎main.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/FasterEdge/SimpleWebShell-RemoteUpdate/internal/workflow"
1717
)
1818

19-
var version = "1.0.20260902"
19+
var version = "1.0.20261022"
2020

2121
func main() {
2222
os.Exit(run(os.Args[1:]))

0 commit comments

Comments
 (0)