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