diff --git a/.github/actions/build-toolchain/action.yml b/.github/actions/build-toolchain/action.yml new file mode 100644 index 0000000..2757d9f --- /dev/null +++ b/.github/actions/build-toolchain/action.yml @@ -0,0 +1,63 @@ +name: Build Toolchain +inputs: + machine: + required: true + type: string + os: + required: true + type: string + arch: + required: true + type: string + build-type: + default: Release + required: true + type: string + +outputs: + install-prefix: ${{steps.set-output.outputs.install-prefix}} + +runs: + using: 'composite' + steps: + - name: Install GCC 12 (Linux) + if: inputs.os == 'linux' + shell: bash + run: | + sudo apt-get update -y + sudo apt-get install -y gcc-12 g++-12 + + - name: Set Parallel Level (macOS) + if: inputs.os == 'darwin' + shell: bash + run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV + + - name: Set Parallel Level + if: inputs.os == 'linux' + shell: bash + run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)" >> $GITHUB_ENV + + - name: Configure CMake + shell: bash + run: | + cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{inputs.build-type}} \ + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot + env: + CC: 'gcc-12' + CXX: 'g++-12' + LANG: 'en_US.UTF-8' + + - name: Build + shell: bash + run: cmake --build ${{github.workspace}}/build --config ${BUILD_TYPE} + env: + LANG: 'en_US.UTF-8' + + - name: Install + shell: bash + run: cmake --install ${{github.workspace}}/build + + - name: Set Output + id: set-output + shell: bash + run: echo "install-prefix=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..68b962f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,50 @@ +name: Build + +on: + workflow_dispatch: + inputs: + machine: + description: 'Host to build for' + required: true + type: choice + options: + - 'macos-12' + - 'macos-14' + - 'debian-arm64-latest' + +jobs: + filter: + name: Select Build Host + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.result }} + steps: + - name: Set Output + id: set-matrix + uses: actions/github-script@v7 + with: + script: | + const machines = [ + {machine: 'macos-12', os: 'darwin', arch: 'x86_64', name: 'macOS x86_64'}, + {machine: 'macos-14', os: 'darwin', arch: 'arm64', name: 'macOS ARM64'}, + {machine: 'debian-arm64-latest', os: 'linux', arch: 'aarch64', name: 'Linux ARM64'} + ]; + return machines.filter(machine => machine.machine === '${{ github.event.inputs.machine }}'); + + build: + name: Build for ${{ matrix.name }} + needs: filter + strategy: + matrix: + include: ${{ fromJson(needs.filter.outputs.matrix) }} + runs-on: ${{ matrix.machine }} + + steps: + - uses: actions/checkout@v4 + + - name: Build Toolchain + uses: './.github/actions/build-toolchain' + with: + machine: ${{ matrix.machine }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 37fa393..febafaf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,101 +9,52 @@ permissions: env: BUILD_TYPE: Release + LANG: 'en_US.UTF-8' jobs: - macos-x86_64: - name: macOS x86_64 - runs-on: macos-12 - - steps: - - uses: actions/checkout@v4 - - - name: Download MacPorts - uses: robinraju/release-downloader@v1.9 - with: - repository: "macports/macports-base" - latest: true - fileName: "*-12-Monterey.pkg" - out-file-path: "/tmp" - - - name: Install MacPorts - run: sudo installer -pkg /tmp/MacPorts-*.pkg -target / - - - name: Add MacPorts to PATH - run: echo "/opt/local/bin:/opt/local/sbin" >> $GITHUB_PATH - - - name: Install CMake and GCC - run: sudo port install cmake gcc12 gcc_select - - - name: Configure GCC - run: sudo port select --set gcc mp-gcc12 - - - name: Set Parallel Level - run: echo "CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.logicalcpu)" >> $GITHUB_ENV - - - name: Configure CMake - run: | - cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot - env: - CC: '/opt/local/bin/gcc' - CXX: '/opt/local/bin/g++' - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Install - run: cmake --install ${{github.workspace}}/build - - - name: Make Tarball - run: | - cmake -E tar cjvf arm-webos-linux-gnueabi_sdk-buildroot_darwin-x86_64.tar.bz2 \ - arm-webos-linux-gnueabi_sdk-buildroot - working-directory: ${{github.workspace}}/build/dist - - - name: Create Release - uses: ncipollo/release-action@v1 - with: - name: Release ${{ steps.tagName.outputs.tag }} - allowUpdates: true - omitNameDuringUpdate: true - omitBodyDuringUpdate: true - omitPrereleaseDuringUpdate: true - artifacts: ${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot_darwin-x86_64.tar.bz2 - - linux-arm64: - name: Linux ARM64 - runs-on: debian-arm64-latest - + release: + name: Release for ${{ matrix.display-name }} + strategy: + matrix: + include: + - machine: 'macos-12' + os: 'darwin' + arch: 'x86_64' + display-name: macOS x86_64 + - machine: 'macos-14' + os: 'darwin' + arch: 'arm64' + display-name: macOS ARM64 + - machine: 'debian-arm64-latest' + os: 'linux' + arch: 'aarch64' + display-name: Linux ARM64 + runs-on: ${{ matrix.machine }} env: - LANG: 'en_US.UTF-8' + ARTIFACT_NAME: arm-webos-linux-gnueabi_sdk-buildroot_${{matrix.os}}-${{matrix.arch}}.tar.bz2 steps: - uses: actions/checkout@v4 - - name: Configure CMake - run: | - cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - - - name: Install - run: cmake --install ${{github.workspace}}/build + - id: build-toolchain + name: Build Toolchain + uses: './.github/actions/build-toolchain' + with: + machine: ${{ matrix.machine }} + os: ${{ matrix.os }} + arch: ${{ matrix.arch }} - name: Make Tarball run: | - cmake -E tar cjvf arm-webos-linux-gnueabi_sdk-buildroot_linux-aarch64.tar.bz2 \ - arm-webos-linux-gnueabi_sdk-buildroot - working-directory: ${{github.workspace}}/build/dist + cmake -E tar cjvf ${{env.ARTIFACT_NAME}} arm-webos-linux-gnueabi_sdk-buildroot + working-directory: ${{steps.build-toolchain.outputs.install-prefix}} - name: Create Release uses: ncipollo/release-action@v1 with: - name: Release ${{ steps.tagName.outputs.tag }} + name: Release ${{ github.event.release.tag_name }} allowUpdates: true omitNameDuringUpdate: true omitBodyDuringUpdate: true omitPrereleaseDuringUpdate: true - artifacts: ${{github.workspace}}/build/dist/arm-webos-linux-gnueabi_sdk-buildroot_linux-aarch64.tar.bz2 \ No newline at end of file + artifacts: ${{github.workspace}}/build/dist/${{env.ARTIFACT_NAME}} \ No newline at end of file