buil.yml with cleanup

This commit is contained in:
2025-07-29 11:40:22 +02:00
parent a7d8c4fb33
commit f8d2a5c483

View File

@@ -36,7 +36,7 @@ jobs:
echo "No Rust project found!"
exit 1
fi
native-build:
name: Native Linux Build
needs: detect-project
@@ -57,18 +57,30 @@ jobs:
id: build
working-directory: ${{ needs.detect-project.outputs.project-dir }}
run: |
set -e
cargo build --release --target x86_64-unknown-linux-gnu
binary_name=$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2)
echo "binary_name=$binary_name" >> $GITHUB_OUTPUT
- name: Strip debug symbols
if: success()
working-directory: ${{ needs.detect-project.outputs.project-dir }}
run: strip target/x86_64-unknown-linux-gnu/release/$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2)
run: |
set -e
strip target/x86_64-unknown-linux-gnu/release/$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2)
- name: Upload Linux artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: ${{ needs.detect-project.outputs.project-dir }}-linux
path: ${{ needs.detect-project.outputs.project-dir }}/target/x86_64-unknown-linux-gnu/release/${{ steps.build.outputs.binary_name }}
- name: Cleanup on failure
if: failure()
run: |
echo "Cleaning up Docker images..."
docker system prune -a -f || echo "Docker cleanup failed"
windows-cross:
name: Windows Cross-Compile
@@ -87,19 +99,43 @@ jobs:
override: true
- name: Install mingw cross-compiler
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
run: |
set -e
sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
- name: Build Windows binary
working-directory: ${{ needs.detect-project.outputs.project-dir }}
id: build
run: |
set -e
cargo build --release --target x86_64-pc-windows-gnu
binary_name=$(grep -m1 '^name =' Cargo.toml | cut -d'"' -f2)
x86_64-w64-mingw32-strip target/x86_64-pc-windows-gnu/release/$binary_name.exe
echo "binary_name=$binary_name" >> $GITHUB_OUTPUT
- name: Upload Windows artifact
if: success()
uses: actions/upload-artifact@v3
with:
name: ${{ needs.detect-project.outputs.project-dir }}-windows
path: ${{ needs.detect-project.outputs.project-dir }}/target/x86_64-pc-windows-gnu/release/${{ steps.build.outputs.binary_name }}.exe
path: ${{ needs.detect-project.outputs.project-dir }}/target/x86_64-pc-windows-gnu/release/${{ steps.build.outputs.binary_name }}.exe
- name: Cleanup on failure
if: failure()
run: |
echo "Cleaning up Docker images..."
docker system prune -a -f || echo "Docker cleanup failed"
cleanup:
name: Cleanup
if: always()
needs: [native-build, windows-cross]
runs-on: ubuntu-latest
steps:
- name: Cleanup Docker images
if: contains(needs.*.result, 'failure')
run: |
echo "One or more jobs failed. Performing cleanup..."
docker system prune -a -f || echo "Docker cleanup failed"
env:
DOCKER_CLI_HINTS: false