first try
This commit is contained in:
68
.github/workflows/build.yml
vendored
68
.github/workflows/build.yml
vendored
@@ -3,12 +3,13 @@ name: Rust Cross-Platform Build
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "feature/*", bug/* ]
|
branches: [ "development", "main", "feature/*", bug/* ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "development", "main" ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
DOCKER_IMAGE_NAME: "watcher-agent"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
detect-project:
|
detect-project:
|
||||||
@@ -126,16 +127,67 @@ jobs:
|
|||||||
echo "Cleaning up Docker images..."
|
echo "Cleaning up Docker images..."
|
||||||
docker system prune -a -f || echo "Docker cleanup failed"
|
docker system prune -a -f || echo "Docker cleanup failed"
|
||||||
|
|
||||||
|
docker-build:
|
||||||
|
name: Build Docker Images
|
||||||
|
needs: [native-build, windows-cross]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Download Linux artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: linux-binary
|
||||||
|
path: linux-bin
|
||||||
|
|
||||||
|
- name: Download Windows artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: windows-binary
|
||||||
|
path: 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
|
||||||
|
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 }}
|
||||||
|
build-args: |
|
||||||
|
BINARY_PATH=linux-bin/${{ needs.detect-project.outputs.project-name }}
|
||||||
|
|
||||||
|
- name: Build and push Windows Docker image
|
||||||
|
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 }}
|
||||||
|
build-args: |
|
||||||
|
BINARY_PATH=windows-bin/${{ needs.detect-project.outputs.project-name }}.exe
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Cleanup
|
name: Cleanup
|
||||||
if: always()
|
if: always()
|
||||||
needs: [native-build, windows-cross]
|
needs: [docker-build, native-build, windows-cross]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Cleanup Docker images
|
- name: Cleanup Docker images
|
||||||
if: contains(needs.*.result, 'failure')
|
if: contains(needs.*.result, 'failure')
|
||||||
run: |
|
run: docker system prune -a -f
|
||||||
echo "One or more jobs failed. Performing cleanup..."
|
|
||||||
docker system prune -a -f || echo "Docker cleanup failed"
|
|
||||||
env:
|
|
||||||
DOCKER_CLI_HINTS: false
|
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -8,6 +8,9 @@ target/
|
|||||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
|
BIN
Dockerfile.linux
Normal file
BIN
Dockerfile.linux
Normal file
Binary file not shown.
11
Dockerfile.windows
Normal file
11
Dockerfile.windows
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Using Windows Server Core as base
|
||||||
|
FROM mcr.microsoft.com/windows/servercore:ltsc2022
|
||||||
|
|
||||||
|
# Create app directory
|
||||||
|
WORKDIR C:/app
|
||||||
|
|
||||||
|
# Copy the Windows binary
|
||||||
|
ARG BINARY_PATH
|
||||||
|
COPY ${BINARY_PATH} watcher_agent.exe
|
||||||
|
|
||||||
|
ENTRYPOINT ["C:/app/watcher_agent.exe"]
|
Reference in New Issue
Block a user