diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..263859f --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,49 @@ +name: Build + +on: + workflow_call: + inputs: + runner: + type: string + default: "linux_amd64" + arch: + type: string + default: "amd64" + +jobs: + build: + runs-on: + - ubuntu-latest + - ${{ inputs.runner }} + steps: + - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 + with: + fetch-depth: 0 + - run: | + sudo apt-get update + sudo apt-get install -y build-essential cmake zip + - name: Build + run: | + mkdir -p build + cd build + cmake .. + cmake --build . + - name: Verify binary + run: | + test -f build/usbmakroboard && echo "Binary built successfully" || exit 1 + - name: Create zip archive + run: | + cd build + zip usbmakroboard-linux-${{ inputs.arch }}.zip usbmakroboard + - name: Generate checksum + run: | + cd build + sha256sum usbmakroboard-linux-${{ inputs.arch }}.zip > usbmakroboard-linux-${{ inputs.arch }}.zip.sha256 + - name: Upload artifacts + uses: ChristopherHX/gitea-upload-artifact@v4 + with: + name: usbmakroboard-${{ inputs.arch }} + path: | + build/usbmakroboard-linux-${{ inputs.arch }}.zip + build/usbmakroboard-linux-${{ inputs.arch }}.zip.sha256 + retention-days: 1 diff --git a/.gitea/workflows/cd.yaml b/.gitea/workflows/cd.yaml index 29e6ebb..69ce123 100644 --- a/.gitea/workflows/cd.yaml +++ b/.gitea/workflows/cd.yaml @@ -21,38 +21,10 @@ jobs: - runner: linux_arm64 arch: arm64 artifact_name: usbmakroboard-arm64 - runs-on: - - ubuntu-latest - - ${{ matrix.runner }} - steps: - - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - with: - fetch-depth: 0 - - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake zip - - name: Build - run: | - mkdir -p build - cd build - cmake .. - cmake --build . - - run: | - test -f build/usbmakroboard && echo "Binary built successfully" || exit 1 - - run: | - cd build - zip usbmakroboard-linux-${{ matrix.arch }}.zip usbmakroboard - - run: | - cd build - sha256sum usbmakroboard-linux-${{ matrix.arch }}.zip > usbmakroboard-linux-${{ matrix.arch }}.zip.sha256 - - name: Upload artifacts - uses: ChristopherHX/gitea-upload-artifact@v4 - with: - name: ${{ matrix.artifact_name }} - path: | - build/usbmakroboard-linux-${{ matrix.arch }}.zip - build/usbmakroboard-linux-${{ matrix.arch }}.zip.sha256 - retention-days: 1 + uses: ./.gitea/workflows/build.yaml + with: + runner: ${{ matrix.runner }} + arch: ${{ matrix.arch }} release: needs: build diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 3110c82..5306936 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -5,20 +5,16 @@ on: jobs: build: - runs-on: - - ubuntu-latest - - linux_amd64 - steps: - - uses: actions/checkout@v4 - - run: | - sudo apt-get update - sudo apt-get install -y build-essential cmake - - name: Configure and build - run: | - mkdir -p build - cd build - cmake .. - cmake --build . - - name: Verify binary - run: | - test -f build/usbmakroboard && echo "Binary built successfully" || exit 1 + strategy: + matrix: + include: + - runner: linux_amd64 + arch: amd64 + artifact_name: usbmakroboard-amd64 + - runner: linux_arm64 + arch: arm64 + artifact_name: usbmakroboard-arm64 + uses: ./.gitea/workflows/build.yaml + with: + runner: ${{ matrix.runner }} + arch: ${{ matrix.arch }}