Skip to content

Commit 6b81511

Browse files
committed
fix(action): docker 打包失败 & Assets 没有文件
1 parent 52b2b4d commit 6b81511

2 files changed

Lines changed: 63 additions & 34 deletions

File tree

.github/workflows/docker-image.yml

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,50 @@ jobs:
1919
docker:
2020
runs-on: ubuntu-latest
2121
steps:
22-
-
23-
name: Checkout
24-
uses: actions/checkout@v2
25-
-
26-
name: Set up QEMU
27-
uses: docker/setup-qemu-action@v1
28-
-
29-
name: Set up Docker Buildx
30-
uses: docker/setup-buildx-action@v1
31-
-
32-
name: Login to DockerHub
33-
uses: docker/login-action@v1
22+
- name: 📥 Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: 🔧 Set up QEMU
26+
uses: docker/setup-qemu-action@v3
27+
28+
- name: 🔧 Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: 🔑 Login to DockerHub
32+
uses: docker/login-action@v3
3433
with:
3534
username: ${{ secrets.DOCKERHUB_USERNAME }}
3635
password: ${{ secrets.DOCKERHUB_TOKEN }}
37-
-
38-
name: Generate App Version
39-
run: echo APP_VERSION=`git describe --tags --always` >> $GITHUB_ENV
40-
-
41-
name: Build and push
42-
uses: docker/build-push-action@v2
36+
37+
- name: 📊 Generate App Version
38+
run: |
39+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
40+
echo "APP_VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
41+
else
42+
echo "APP_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
43+
fi
44+
45+
- name: 🔨 Build and push
46+
uses: docker/build-push-action@v5
4347
with:
4448
context: .
45-
platforms: |
46-
linux/386
47-
linux/amd64
48-
linux/arm64
49+
platforms: linux/amd64,linux/arm64 # 移除 linux/386
4950
push: true
5051
build-args: |
5152
APP_NAME=${{ env.APP_NAME }}
5253
APP_VERSION=${{ env.APP_VERSION }}
5354
tags: |
5455
${{ env.DOCKERHUB_REPO }}:latest
55-
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
56+
${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}
57+
cache-from: type=gha
58+
cache-to: type=gha,mode=max
59+
60+
- name: 📋 Docker Image Info
61+
run: |
62+
echo "🎉 Docker 镜像构建完成!"
63+
echo "📦 镜像标签:"
64+
echo " - ${{ env.DOCKERHUB_REPO }}:latest"
65+
echo " - ${{ env.DOCKERHUB_REPO }}:${{ env.APP_VERSION }}"
66+
echo ""
67+
echo "🚀 使用方法:"
68+
echo " docker run -p 12395:12395 ${{ env.DOCKERHUB_REPO }}:latest"

.github/workflows/github-release.yml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,20 +335,36 @@ jobs:
335335
uses: actions/download-artifact@v4
336336
with:
337337
path: artifacts
338-
merge-multiple: true
339338

340-
- name: 📋 验证下载的文件
339+
- name: 🔧 整理发布文件
341340
run: |
342-
echo "📋 已下载的产物:"
343-
find artifacts -type f -name "*.tar.gz" -o -name "*.zip" | sort
344-
echo ""
345-
echo "📊 文件大小和校验和:"
346-
find artifacts -type f -name "*.tar.gz" -o -name "*.zip" | while read file; do
347-
echo "文件: $(basename "$file")"
348-
echo " 大小: $(ls -lh "$file" | awk '{print $5}')"
349-
echo " SHA256: $(sha256sum "$file" | cut -d' ' -f1)"
350-
echo ""
341+
echo "🔧 整理发布文件..."
342+
343+
# 创建发布目录
344+
mkdir -p release-files
345+
346+
# 查看下载的文件结构
347+
echo "📋 下载的文件结构:"
348+
find artifacts -type f | sort
349+
350+
# 移动所有压缩包到发布目录
351+
find artifacts -name "*.tar.gz" -o -name "*.zip" | while read file; do
352+
filename=$(basename "$file")
353+
echo "📦 移动文件: $filename"
354+
cp "$file" "release-files/$filename"
351355
done
356+
357+
# 验证发布文件
358+
echo "📊 准备发布的文件:"
359+
ls -la release-files/
360+
361+
# 生成校验和文件
362+
cd release-files
363+
echo "🔐 生成校验和..."
364+
sha256sum *.tar.gz *.zip > SHA256SUMS 2>/dev/null || true
365+
366+
echo "📋 校验和文件内容:"
367+
cat SHA256SUMS || echo "未生成校验和文件"
352368
353369
- name: 📋 创建 GitHub 发布
354370
uses: softprops/action-gh-release@v2

0 commit comments

Comments
 (0)