Skip to content

fix(sh): fix run-qemu.sh #12

fix(sh): fix run-qemu.sh

fix(sh): fix run-qemu.sh #12

Workflow file for this run

name: Build and Publish to CNB
on:
push:
branches: [ master ]
paths: [ tools/BUILD_CONTAINER_VERSION ] # 必须包含对版本的修改
workflow_dispatch: # 允许手动触发
env:
# 设置镜像名和构建产物的名称
IMAGE_NAME: docker.cnb.cool/alinche/linux-minimal
ARTIFACT_NAME: myminilinux-build-artifacts
jobs:
build:
name: Build Linux Minimal
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential g++ qemu-utils parted dosfstools e2fsprogs udev kpartx grub2-common
- name: Build Project
run: |
echo "开始构建..."
make build
make make_diskimage
mkdir -p build bin/vmlinuz
tar -czf "${{ env.ARTIFACT_NAME }}.tar.gz" build bin/vmlinuz/vmlinuz-x86_64
ls -lh "${{ env.ARTIFACT_NAME }}.tar.gz"
- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: "${{ env.ARTIFACT_NAME }}.tar.gz"
retention-days: 1
publish:
name: Publish Docker Image
needs: build # 必须等待 build 任务成功
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# 这里 checkout 主要是为了获取 Dockerfile
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
# 下载到当前目录,这样 Docker build 就能找到了
path: .
- name: Debug - List Files
run: |
echo "当前目录是: $(pwd)"
ls -lhR
- name: Fetch versions in the repo
id: fetch_versions
run: |
BUILD_CONTAINER_VERSION=$(cat tools/BUILD_CONTAINER_VERSION)
echo "build_container_version=$BUILD_CONTAINER_VERSION" >> "$GITHUB_OUTPUT"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to CNB Registry
uses: docker/login-action@v2
with:
registry: docker.cnb.cool
username: cnb
password: ${{ secrets.CNB_TOKEN }}
# - name: Generate Tag
# id: meta
# run: |
# # 生成类似 :20251218-66ccff 的标签
# SHA_SHORT=$(git rev-parse --short HEAD)
# DATE_TAG=$(date +%Y%m%d)
# echo "tag=${DATE_TAG}-${SHA_SHORT}" >> $GITHUB_OUTPUT
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: .
file: tools/Dockerfile
platforms: linux/amd64
push: ${{ github.repository == 'oeasy1412/Linux-minimal' }}
build-args: |
TAR_FILE=${{ env.ARTIFACT_NAME }}.tar.gz
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ steps.fetch_versions.outputs.build_container_version }}