check for artifacts

This commit is contained in:
2025-08-02 17:31:40 +02:00
parent b06c15ff4e
commit 1a69e3fc78

View File

@@ -24,16 +24,22 @@ jobs:
- name: Find Cargo.toml
id: detect
run: |
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
PROJECT_DIR="$dir"
PROJECT_NAME=$(grep -m1 '^name =' "$dir/Cargo.toml" | cut -d'"' -f2)
echo "project-dir=${PROJECT_DIR%/}" >> $GITHUB_OUTPUT
echo "project-name=${PROJECT_NAME}" >> $GITHUB_OUTPUT
break
fi
done
if [ -z "$PROJECT_DIR" ]; then
# Look for Cargo.toml in root or subdirectories
if [ -f "Cargo.toml" ]; then
echo "project-dir=." >> $GITHUB_OUTPUT
PROJECT_NAME=$(grep -m1 '^name =' "Cargo.toml" | cut -d'"' -f2)
echo "project-name=${PROJECT_NAME}" >> $GITHUB_OUTPUT
else
for dir in */; do
if [ -f "$dir/Cargo.toml" ]; then
echo "project-dir=${dir%/}" >> $GITHUB_OUTPUT
PROJECT_NAME=$(grep -m1 '^name =' "$dir/Cargo.toml" | cut -d'"' -f2)
echo "project-name=${PROJECT_NAME}" >> $GITHUB_OUTPUT
break
fi
done
fi
if [ -z "$PROJECT_NAME" ]; then
echo "No Rust project found!"
exit 1
fi
@@ -71,12 +77,11 @@ jobs:
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: linux-binary
path: ${{ steps.build-linux.outputs.binary_path }}
- name: Cleanup on failure
if: failure()
run: |
@@ -115,11 +120,10 @@ jobs:
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
name: windows-binary
path: ${{ steps.build-windows.outputs.binary_path }}
- name: Cleanup on failure
if: failure()
@@ -146,39 +150,37 @@ jobs:
name: windows-binary
path: windows-bin
- name: Verify artifacts
run: |
echo "Linux binary:"
ls -la linux-bin/
echo "Windows binary:"
ls -la windows-bin/
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Linux Docker image
- name: Build Linux Docker image
if: ${{ always() && steps.download-linux.outcome == 'success' }}
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.linux
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.DOCKER_IMAGE_NAME }}:linux-latest
${{ env.DOCKER_IMAGE_NAME }}:linux-${{ github.sha }}
push: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:linux-latest
build-args: |
BINARY_PATH=linux-bin/${{ needs.detect-project.outputs.project-name }}
- name: Build and push Windows Docker image
- name: Build Windows Docker image
if: ${{ always() && steps.download-windows.outcome == 'success' }}
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.windows
platforms: windows-amd64
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.DOCKER_IMAGE_NAME }}:windows-latest
${{ env.DOCKER_IMAGE_NAME }}:windows-${{ github.sha }}
push: false
tags: ${{ env.DOCKER_IMAGE_NAME }}:windows-latest
build-args: |
BINARY_PATH=windows-bin/${{ needs.detect-project.outputs.project-name }}.exe