diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 877abbd8..087fbce1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,47 +1,140 @@ -name: dvmhost-build +# Author: K4YT3X -# Controls when the workflow will run +name: dvmhost-build on: - # Allows you to run this workflow manually from the Actions tab workflow_dispatch: - #run on push/PR + inputs: + buildType: + description: 'CMake Build Type' + required: true + default: 'Release' + type: choice + options: + - Release + - Debug + - RelWithDebInfo + - MinSizeRel + stripSymbols: + description: 'Strip Symbols' + required: false + type: boolean push: - branches: [ master ] + branches: + - master pull_request: - branches: [ master ] + branches: + - master -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release +permissions: + contents: write -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" + setup: + name: Setup + runs-on: ubuntu-latest + outputs: + APPNAME: ${{ steps.get_appname.outputs.APPNAME }} + DATE: ${{ steps.get_date.outputs.DATE }} + steps: + - name: Get app name + id: get_appname + run: echo APPNAME=${{ github.event.repository.name }} >> $GITHUB_OUTPUT + - name: Get date + id: get_date + run: echo DATE=$(date +'%Y-%m-%d') >> $GITHUB_OUTPUT + build: + name: Build + needs: [setup] + strategy: + matrix: + arch: ["amd64", "arm", "aarch64", "armhf"] runs-on: ubuntu-latest + env: + PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.DATE }}-${{ matrix.arch }} + DEBIAN_FRONTEND: noninteractive steps: - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v5.1 - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout + - name: Checkout repository uses: actions/checkout@v3 - - - name: Install Dependencies - run: sudo apt-get install -y gcc-arm-none-eabi cmake build-essential devscripts debhelper libasio-dev - - - name: Sync Git Submodules - run: git submodule init && git submodule update - - - name: Change /opt Permissions - run: sudo chmod 777 /opt - - - name: Generate build files with CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build binaries - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j $(nproc) + with: + submodules: recursive + - name: Install dependencies + run: | + sudo apt-get install -y git build-essential cmake \ + g++-arm-linux-gnueabihf \ + gcc-arm-linux-gnueabihf \ + g++-aarch64-linux-gnu \ + libasio-dev + - name: Build + run: | + if [[ "${{ github.event_name }}" == 'push' ]]; then + build_args="-DCMAKE_BUILD_TYPE=${{ inputs.buildType }}" + if [[ "${{ inputs.stripSymbols }}" == 'true' ]]; then + build_args="$build_args -DCMAKE_C_FLAGS='-s' -DCMAKE_CXX_FLAGS='-s'" + fi + else + build_args='-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s"' + fi + + if [[ "${{ matrix.arch }}" == 'armhf' ]]; then + git clone https://github.com/chriskohlhoff/asio.git + cmake $(echo $build_args) -DCROSS_COMPILE_RPI_ARM=1 -DWITH_ASIO='asio/asio' . + else + cmake $(echo $build_args) \ + -D "CROSS_COMPILE_$(echo '${{ matrix.arch }}' | tr '[:lower:]' '[:upper:]')=1" . + fi + + make -j $(nproc) + - name: Package + run: | + mkdir -p ${{ env.PACKAGENAME }} + cp dvmcmd dvmhost ${{ env.PACKAGENAME }} + zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }} + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }} + path: ${{ env.PACKAGENAME }}.zip + + create-release: + if: ${{ github.event == 'push' }} + name: Create Release + needs: [setup, build] + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create release + id: create_release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.setup.outputs.DATE }} + name: Nightly Build ${{ needs.setup.outputs.DATE }} + draft: false + prerelease: true + + upload: + if: ${{ github.event == 'push' }} + name: Upload + needs: [setup, build, create-release] + strategy: + matrix: + arch: ["amd64", "arm", "aarch64", "armhf"] + runs-on: ubuntu-latest + env: + PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.DATE }}-${{ matrix.arch }} + DEBIAN_FRONTEND: noninteractive + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }} + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: ${{ env.PACKAGENAME }}.zip + asset_name: ${{ env.PACKAGENAME }}.zip + asset_content_type: application/zip diff --git a/.github/workflows/dpkg.yml b/.github/workflows/dpkg.yml deleted file mode 100644 index 4a2869de..00000000 --- a/.github/workflows/dpkg.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: dvmhost-build-dpkg - -# Controls when the workflow will run -on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - runs-on: ubuntu-latest - steps: - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v5.1 - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Dependencies - run: sudo apt-get install -y gcc-arm-none-eabi build-essential devscripts debhelper libasio-dev - - - name: Sync Git Submodules - run: git submodule init && git submodule update - - - name: Generate build files with CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build binaries - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j $(nproc) - - - name: Change /opt Permissions - run: sudo chmod 777 /opt - - - name: Build Debian Package - run: | - cd ${{github.workspace}}/build - cpack - - - name: Package Hash - run: | - echo "BRANCH: ${{steps.branch-name.outputs.current_branch}}" >> release.txt - echo "COMMIT: ${{github.sha}}" >> release.txt - echo >> release.txt - echo '```' >> release.txt - cat << EOF >> release.txt - dvmhost_3.0.0-1_amd64.deb - size : $(wc -c dvmhost_3.0.0-1_amd64.deb) - md5 : $(md5sum dvmhost_3.0.0-1_amd64.deb) - sha1 : $(sha1sum dvmhost_3.0.0-1_amd64.deb) - sha256: $(sha256sum dvmhost_3.0.0-1_amd64.deb) - EOF - echo '```' >> release.txt - - - name: Release Artifacts - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{steps.date.outputs.date}} - body_path: release.txt - files: | - dvmhost_3.0.0-1_amd64.deb diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml deleted file mode 100644 index e52e0cd1..00000000 --- a/.github/workflows/prerelease.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: dvmhost-build-prerelease - -# Controls when the workflow will run -on: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - #run on push/PR - push: - branches: [ master ] - pull_request: - branches: [ master ] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - runs-on: ubuntu-latest - steps: - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v5.1 - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y-%m-%d')" - - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Dependencies - run: sudo apt-get install -y gcc-arm-none-eabi cmake build-essential devscripts debhelper libasio-dev - - - name: Sync Git Submodules - run: git submodule init && git submodule update - - - name: Change /opt Permissions - run: sudo chmod 777 /opt - - - name: Generate build files with CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build binaries - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -- -j $(nproc) - - - name: Package Hash - run: | - echo "BRANCH: ${{steps.branch-name.outputs.current_branch}}" >> release.txt - echo "COMMIT: ${{github.sha}}" >> release.txt - echo >> release.txt - echo '```' >> release.txt - cat << EOF >> release.txt - dvmhost - size : $(wc -c ${{github.workspace}}/build/dvmhost) - md5 : $(md5sum ${{github.workspace}}/build/dvmhost) - sha1 : $(sha1sum ${{github.workspace}}/build/dvmhost) - sha256: $(sha256sum ${{github.workspace}}/build/dvmhost) - EOF - echo '```' >> release.txt - - - name: Release Artifacts - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{steps.date.outputs.date}} - body_path: release.txt - prerelease: true - files: | - ${{github.workspace}}/build/dvmhost diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c4cf0ef..3a832def 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,7 @@ permissions: jobs: setup: + name: Setup runs-on: ubuntu-latest outputs: APPNAME: ${{ steps.get_appname.outputs.APPNAME }} @@ -24,28 +25,12 @@ jobs: id: get_version run: echo VERSION=${GITHUB_REF/refs\/tags\//} >> $GITHUB_OUTPUT - create-release: - needs: - - setup - name: Create Release - runs-on: ubuntu-latest - outputs: - upload_url: ${{ steps.create_release.outputs.upload_url }} - steps: - - name: Create release - id: create_release - uses: softprops/action-gh-release@v1 - with: - tag_name: ${{ needs.setup.outputs.VERSION }} - name: Release ${{ needs.setup.outputs.VERSION }} - draft: true - prerelease: false - - ubuntu: + build: + name: Build + needs: [setup] strategy: matrix: - arch: ["AMD64", "ARM", "AARCH64", "RPI_ARM"] - needs: [setup, create-release] + arch: ["amd64", "arm", "aarch64", "armhf"] runs-on: ubuntu-latest env: PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-${{ matrix.arch }} @@ -65,16 +50,13 @@ jobs: libasio-dev - name: Build run: | - if [[ "${{ matrix.arch }}" == "RPI_ARM" ]]; then - sudo sed -i 's/^# deb-src/deb-src/g' /etc/apt/sources.list - sudo apt-get update - sudo apt-get source asio + if [[ "${{ matrix.arch }}" == 'armhf' ]]; then + git clone https://github.com/chriskohlhoff/asio.git cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" \ - -DENABLE_DMR=1 -DENABLE_P25=1 -DENABLE_NXDN=1 -DCROSS_COMPILE_${{ matrix.arch }}=1 \ - -DWITH_ASIO="$(realpath -e $(find . -maxdepth 1 -type d -iname 'asio*'))" . + -DCROSS_COMPILE_RPI_ARM=1 -DWITH_ASIO='asio/asio' . else cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-s" -DCMAKE_CXX_FLAGS="-s" \ - -DENABLE_DMR=1 -DENABLE_P25=1 -DENABLE_NXDN=1 -DCROSS_COMPILE_${{ matrix.arch }}=1 . + -D "CROSS_COMPILE_$(echo '${{ matrix.arch }}' | tr '[:lower:]' '[:upper:]')=1" . fi make -j $(nproc) @@ -83,7 +65,44 @@ jobs: mkdir -p ${{ env.PACKAGENAME }} cp dvmcmd dvmhost ${{ env.PACKAGENAME }} zip -9 -r ${{ env.PACKAGENAME }}.zip ${{ env.PACKAGENAME }} - - name: Upload + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }} + path: ${{ env.PACKAGENAME }}.zip + + create-release: + name: Create Release + needs: [setup, build] + runs-on: ubuntu-latest + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + steps: + - name: Create release + id: create_release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ needs.setup.outputs.VERSION }} + name: Release ${{ needs.setup.outputs.VERSION }} + draft: true + prerelease: false + + upload: + name: Upload + needs: [setup, build, create-release] + strategy: + matrix: + arch: ["amd64", "arm", "aarch64", "armhf"] + runs-on: ubuntu-latest + env: + PACKAGENAME: ${{ needs.setup.outputs.APPNAME }}-${{ needs.setup.outputs.VERSION }}-${{ matrix.arch }} + DEBIAN_FRONTEND: noninteractive + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: ${{ needs.setup.outputs.APPNAME }}-${{ matrix.arch }} + - name: Upload release asset uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}