Update build.yml #16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: F3 CI/CD | |
| on: [push, pull_request] | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest] | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Cygwin (Windows only) | |
| if: matrix.os == 'windows-latest' | |
| uses: cygwin/cygwin-install-action@v2 | |
| with: | |
| platform: x86_64 | |
| packages: gcc-core make libargp-devel libparted-devel libudev-devel | |
| install-dir: C:/cygwin64 | |
| - name: Setup environment | |
| shell: bash | |
| run: | | |
| case "${{ matrix.os }}" in | |
| windows-latest) | |
| export CYGWIN_ROOT="/cygdrive/c/cygwin64" | |
| export PATH="$CYGWIN_ROOT/bin:$PATH" | |
| ;; | |
| ubuntu-latest) | |
| sudo apt-get update | |
| sudo apt-get install -y libudev-dev libparted-dev | |
| ;; | |
| esac | |
| - name: Build all targets | |
| shell: bash | |
| env: | |
| CC: gcc | |
| run: | | |
| case "${{ matrix.os }}" in | |
| windows-latest) | |
| export ARGP_PATH="$CYGWIN_ROOT/usr/local" | |
| make CC="gcc" EXTRA_CFLAGS="-DWINDOWS_COMPAT" all | |
| ;; | |
| *) | |
| make all | |
| ;; | |
| esac | |
| - name: Collect artifacts | |
| shell: bash | |
| run: | | |
| mkdir -p artifacts | |
| case "${{ matrix.os }}" in | |
| windows-latest) | |
| cp *.exe artifacts/ | |
| ;; | |
| *) | |
| cp f3* artifacts/ | |
| ;; | |
| esac | |
| - name: Upload binaries | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: f3-${{ matrix.os }}-binaries | |
| path: artifacts/ | |
| if-no-files-found: error | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t f3 . | |
| - name: Extract Docker artifacts | |
| run: | | |
| mkdir -p docker-artifacts | |
| docker run --rm -v $(pwd)/docker-artifacts:/out f3 bash -c "cp /usr/local/bin/f3* /out/" | |
| - name: Upload Docker artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-f3-binaries | |
| path: docker-artifacts/ |