|
| 1 | +name: HW Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + release: |
| 8 | + types: [published] |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - '**' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + # SHA is added to the end if on `main` to let all main workflows run |
| 16 | + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/heads/long_lived/')) && github.sha || '' }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: write |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-hw: |
| 24 | + name: Build HW VDF Client |
| 25 | + runs-on: [ubuntu-latest] |
| 26 | + steps: |
| 27 | + - name: Checkout code |
| 28 | + uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Set Env |
| 33 | + uses: Chia-Network/actions/setjobenv@main |
| 34 | + env: |
| 35 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Install deps |
| 38 | + run: | |
| 39 | + sudo apt-get update |
| 40 | + sudo apt-get install -y build-essential cmake libgmp-dev libboost-system-dev |
| 41 | +
|
| 42 | + - name: Download USB drivers |
| 43 | + run: | |
| 44 | + mkdir libft4222 |
| 45 | + cd libft4222 |
| 46 | + wget https://download.chia.net/vdf/libft4222-linux-1.4.4.170.tgz |
| 47 | + tar -xvzf libft4222-linux-1.4.4.170.tgz |
| 48 | + ln -s ${{ github.workspace }}/libft4222 ${{ github.workspace }}/src/hw/libft4222 |
| 49 | + ln -s ${{ github.workspace }}/libft4222/build-x86_64/libft4222.so.1.4.4.170 ${{ github.workspace }}/libft4222/build-x86_64/libft4222.so |
| 50 | +
|
| 51 | + - name: Compile |
| 52 | + working-directory: "${{ github.workspace }}/src" |
| 53 | + run: make -f Makefile.vdf-client emu_hw_test hw_test emu_hw_vdf_client hw_vdf_client |
| 54 | + |
| 55 | + - name: Upload Artifacts |
| 56 | + uses: actions/upload-artifact@v3 |
| 57 | + with: |
| 58 | + name: hw-vdf |
| 59 | + path: | |
| 60 | + ${{ github.workspace }}/src/emu_hw_test |
| 61 | + ${{ github.workspace }}/src/hw_test |
| 62 | + ${{ github.workspace }}/src/hw_vdf_client |
| 63 | + ${{ github.workspace }}/src/emu_hw_vdf_client |
| 64 | + ${{ github.workspace }}/src/hw/libft4222/build-x86_64/libft4222.so |
| 65 | +
|
| 66 | + - name: Assemble .deb |
| 67 | + env: |
| 68 | + INSTALLER_VERSION: "${{ env.RELEASE_TAG || format('0.0.1-{0}', github.run_id) }}" |
| 69 | + PLATFORM: "amd64" |
| 70 | + run: | |
| 71 | + pip install j2cli |
| 72 | + CLI_DEB_BASE="chiavdf-hw_$INSTALLER_VERSION-1_$PLATFORM" |
| 73 | + mkdir -p "dist/$CLI_DEB_BASE/usr/bin" |
| 74 | + mkdir -p "dist/$CLI_DEB_BASE/usr/lib" |
| 75 | + mkdir -p "dist/$CLI_DEB_BASE/DEBIAN" |
| 76 | + mkdir -p "dist/$CLI_DEB_BASE/etc/udev/rules.d" |
| 77 | + j2 -o "dist/$CLI_DEB_BASE/DEBIAN/control" assets/deb/control.j2 |
| 78 | +
|
| 79 | + cp ${{ github.workspace }}/src/emu_hw_test dist/$CLI_DEB_BASE/usr/bin/ |
| 80 | + cp ${{ github.workspace }}/src/hw_test dist/$CLI_DEB_BASE/usr/bin/ |
| 81 | + cp ${{ github.workspace }}/src/hw_vdf_client dist/$CLI_DEB_BASE/usr/bin/ |
| 82 | + cp ${{ github.workspace }}/src/emu_hw_vdf_client dist/$CLI_DEB_BASE/usr/bin/ |
| 83 | + cp ${{ github.workspace }}/src/hw/libft4222/build-x86_64/libft4222.so dist/$CLI_DEB_BASE/usr/lib/ |
| 84 | + echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="601c", MODE="0666"' > dist/$CLI_DEB_BASE/etc/udev/rules.d/99-chiavdf.rules |
| 85 | + dpkg-deb --build --root-owner-group "dist/$CLI_DEB_BASE" |
| 86 | +
|
| 87 | + echo "DEB_NAME=$CLI_DEB_BASE.deb" >> $GITHUB_ENV |
| 88 | +
|
| 89 | + - name: Upload Installer |
| 90 | + uses: actions/upload-artifact@v3 |
| 91 | + with: |
| 92 | + name: installer |
| 93 | + path: | |
| 94 | + ${{ github.workspace }}/dist/${{ env.DEB_NAME }} |
| 95 | +
|
| 96 | + - name: Upload release artifacts |
| 97 | + if: env.RELEASE == 'true' |
| 98 | + env: |
| 99 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + run: | |
| 101 | + gh release upload \ |
| 102 | + $RELEASE_TAG \ |
| 103 | + dist/${{ env.DEB_NAME }} |
0 commit comments