From 2f82532f7e94b0f953f2845f49cc405af5abc850 Mon Sep 17 00:00:00 2001 From: "Horgan, Emmet" Date: Tue, 27 Aug 2024 17:02:34 +0100 Subject: [PATCH] Build workflow for macOS (#36) * Add macos build workflows which builds a release and debug version of OpenOCD on a ARM64 MacOS runner and uploads the artifact to JFrog * Add debug and snapshot workflows for MacOS --- .github/workflows/build_debug_macos.yml | 116 ++++++++++++++++++ .github/workflows/release_adi_macos.yml | 142 +++++++++++++++++++++++ .github/workflows/snapshot_adi_macos.yml | 133 +++++++++++++++++++++ 3 files changed, 391 insertions(+) create mode 100644 .github/workflows/build_debug_macos.yml create mode 100644 .github/workflows/release_adi_macos.yml create mode 100644 .github/workflows/snapshot_adi_macos.yml diff --git a/.github/workflows/build_debug_macos.yml b/.github/workflows/build_debug_macos.yml new file mode 100644 index 000000000..f26bef0af --- /dev/null +++ b/.github/workflows/build_debug_macos.yml @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Copyright (C) 2024 Analog Devices, Inc. + +on: + push: + branches: [ "**/**", "!adi-main", "!milestone/**" ] + workflow_dispatch: + + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +name: OpenOCD macOS Debug Build + +env: + DEPS_DIR: "${GITHUB_WORKSPACE}/openocd_deps" + +jobs: + build: + runs-on: [self-hosted, macOS, ARM64] + strategy: + matrix: + platform: [ + { + name: "macOS-ARM64", + compiler_flags: "-g -Wno-error", + linker_flags: "-L${GITHUB_WORKSPACE}/openocd_deps/lib", + configure_options: "--prefix=${GITHUB_WORKSPACE}/output/openocd", + pkg_cfg_path: "" + }, + ] + + steps: + - name: Cleanup Workspace + run: | + rm -rf ./* ./.??* + + - name: Checkout ${{ matrix.platform.name }} + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: openocd + fetch-depth: 0 + persist-credentials: false + + - name: Checkout libusb + uses: actions/checkout@v4 + with: + repository: libusb/libusb + ref: v1.0.24 + path: libusb + fetch-depth: 0 + persist-credentials: false + + - name: Checkout hidapi + uses: actions/checkout@v4 + with: + repository: libusb/hidapi + ref: hidapi-0.13.1 + path: hidapi + fetch-depth: 0 + persist-credentials: false + + - name: Build libusb + run: | + cd libusb &&\ + ./bootstrap.sh &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build hidapi + run: | + cd hidapi &&\ + ./bootstrap &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build ${{ matrix.platform.name }} + env: + PKG_CONFIG_PATH: ${{ matrix.platform.pkg_cfg_path }} + CPPFLAGS: ${{ matrix.platform.compiler_flags }} + CFLAGS: ${{ matrix.platform.compiler_flags }} + LDFLAGS: ${{ matrix.platform.linker_flags }} + run: | + cd openocd &&\ + ./bootstrap &&\ + ./configure ${{ matrix.platform.configure_options }} &&\ + make -j$(nproc) &&\ + cd .. + + - name: Install to local folder + run: | + cd openocd &&\ + make install &&\ + cd .. + + - name: Generate ARTIFACT_NAME + run: | + echo "ARTIFACT_NAME=openocd-${{ github.ref_name }}-${{ matrix.platform.name }}-${{ matrix.build.name }}" | tr '/' '-' >> $GITHUB_ENV + + - name: Zip files + run: + cd output && zip -qq -r ../${{ env.ARTIFACT_NAME }}.zip openocd/ + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_NAME }} + path: "output" + retention-days: 30 \ No newline at end of file diff --git a/.github/workflows/release_adi_macos.yml b/.github/workflows/release_adi_macos.yml new file mode 100644 index 000000000..e9a6ed82f --- /dev/null +++ b/.github/workflows/release_adi_macos.yml @@ -0,0 +1,142 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Copyright (C) 2024 Analog Devices, Inc. + +on: + push: + tags: + - '[0-9]+\.[0-9]+\.[0-9]+-[0-9]+\.[0-9]+\.[0-9]+' + + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +name: OpenOCD macOS Release Build + +env: + DEPS_DIR: "${GITHUB_WORKSPACE}/openocd_deps" + +jobs: + build: + runs-on: [self-hosted, macOS, ARM64] + strategy: + matrix: + platform: [ + { + name: "macOS-ARM64", + configure_options: "--prefix=${GITHUB_WORKSPACE}/output/openocd", + pkg_cfg_path: "" + }, + ] + build: [ + { + name: "release", + compiler_flags: "-O2 -Wno-error", + linker_flags: "-L${GITHUB_WORKSPACE}/openocd_deps/lib" + }, + { + name: "debug", + compiler_flags: "-g -Wno-error", + linker_flags: "-L${GITHUB_WORKSPACE}/openocd_deps/lib" + } + ] + + steps: + - name: Cleanup Workspace + run: | + rm -rf ./* ./.??* + + - name: Checkout ${{ matrix.platform.name }} + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: openocd + fetch-depth: 0 + persist-credentials: false + + - name: Checkout libusb + uses: actions/checkout@v4 + with: + repository: libusb/libusb + ref: v1.0.24 + path: libusb + fetch-depth: 0 + persist-credentials: false + + - name: Checkout hidapi + uses: actions/checkout@v4 + with: + repository: libusb/hidapi + ref: hidapi-0.13.1 + path: hidapi + fetch-depth: 0 + persist-credentials: false + + - name: Get Tag + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + - name: Package Version + run: | + PKG_VERSION="Analog Devices ${{ env.TAG_NAME }}" + echo "CONF_OPTS=${{ matrix.platform.configure_options }} --with-pkgversion=\"${PKG_VERSION}\"" >> $GITHUB_ENV + + - name: Build libusb + run: | + cd libusb &&\ + ./bootstrap.sh &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build hidapi + run: | + cd hidapi &&\ + ./bootstrap &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build ${{ matrix.platform.name }} + env: + PKG_CONFIG_PATH: ${{ matrix.platform.pkg_cfg_path }} + CPPFLAGS: ${{ matrix.build.compiler_flags }} + CFLAGS: ${{ matrix.build.compiler_flags }} + LDFLAGS: ${{ matrix.build.linker_flags }} + + run: | + cd openocd &&\ + ./bootstrap &&\ + ./configure ${{ env.CONF_OPTS }} &&\ + make -j$(nproc) &&\ + cd .. + + - name: Install to local folder + run: | + cd openocd &&\ + make install &&\ + cd .. + + - name: Generate ARTIFACT_NAME + run: | + echo "ARTIFACT_NAME=openocd-${{ env.TAG_NAME }}-${{ matrix.platform.name }}-${{ matrix.build.name }}" | tr '/' '-' >> $GITHUB_ENV + + - name: Zip files + run: + cd output && zip -qq -r ../${{ env.ARTIFACT_NAME }}.zip openocd/ + + - name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v4 + env: + JF_URL: ${{ vars.ARTIFACTORY_URL }} + JF_USER: ${{ secrets.JF_USER }} + JF_PASSWORD: ${{ secrets.JF_PASSWORD }} + + - name: Run JFrog CLI + run: | + # Ping the server + jf rt ping + jf rt u "${{ env.ARTIFACT_NAME }}.zip" "dte-products/standalone/openocd/${{ github.ref_name }}/${{ env.ARTIFACT_NAME }}.zip" \ No newline at end of file diff --git a/.github/workflows/snapshot_adi_macos.yml b/.github/workflows/snapshot_adi_macos.yml new file mode 100644 index 000000000..2074c7aaa --- /dev/null +++ b/.github/workflows/snapshot_adi_macos.yml @@ -0,0 +1,133 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Copyright (C) 2024 Analog Devices, Inc. + +on: + push: + branches: [ "adi-main", "milestone/**" ] + workflow_dispatch: + + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +name: OpenOCD macOS Snapshot Build + +env: + DEPS_DIR: "${GITHUB_WORKSPACE}/openocd_deps" + +jobs: + build: + runs-on: [self-hosted, macOS, ARM64] + strategy: + matrix: + platform: [ + { + name: "macOS-ARM64", + configure_options: "--prefix=${GITHUB_WORKSPACE}/output/openocd", + pkg_cfg_path: "" + }, + ] + build: [ + { + name: "release", + compiler_flags: "-O2 -Wno-error", + linker_flags: "-L${GITHUB_WORKSPACE}/openocd_deps/lib" + }, + { + name: "debug", + compiler_flags: "-g -Wno-error", + linker_flags: "-L${GITHUB_WORKSPACE}/openocd_deps/lib" + } + ] + + steps: + - name: Cleanup Workspace + run: | + rm -rf ./* ./.??* + + - name: Checkout ${{ matrix.platform.name }} + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + path: openocd + fetch-depth: 0 + persist-credentials: false + + - name: Checkout libusb + uses: actions/checkout@v4 + with: + repository: libusb/libusb + ref: v1.0.24 + path: libusb + fetch-depth: 0 + persist-credentials: false + + - name: Checkout hidapi + uses: actions/checkout@v4 + with: + repository: libusb/hidapi + ref: hidapi-0.13.1 + path: hidapi + fetch-depth: 0 + persist-credentials: false + + - name: Build libusb + run: | + cd libusb &&\ + ./bootstrap.sh &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build hidapi + run: | + cd hidapi &&\ + ./bootstrap &&\ + ./configure --prefix=${{ env.DEPS_DIR }} --disable-shared --enable-static &&\ + make -j$(nproc) &&\ + make install &&\ + cd .. + + - name: Build ${{ matrix.platform.name }} + env: + PKG_CONFIG_PATH: ${{ matrix.platform.pkg_cfg_path }} + CPPFLAGS: ${{ matrix.build.compiler_flags }} + CFLAGS: ${{ matrix.build.compiler_flags }} + LDFLAGS: ${{ matrix.build.linker_flags }} + + run: | + cd openocd &&\ + ./bootstrap &&\ + ./configure ${{ matrix.platform.configure_options }} &&\ + make -j$(nproc) &&\ + cd .. + + - name: Install to local folder + run: | + cd openocd &&\ + make install &&\ + cd .. + + - name: Generate ARTIFACT_NAME + run: | + echo "ARTIFACT_NAME=openocd-${{ github.ref_name }}-${{ matrix.platform.name }}-${{ matrix.build.name }}" | tr '/' '-' >> $GITHUB_ENV + + - name: Zip files + run: + cd output && zip -qq -r ../${{ env.ARTIFACT_NAME }}.zip openocd/ + + - name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v4 + env: + JF_URL: ${{ vars.ARTIFACTORY_URL }} + JF_USER: ${{ secrets.JF_USER }} + JF_PASSWORD: ${{ secrets.JF_PASSWORD }} + + - name: Run JFrog CLI + run: | + # Ping the server + jf rt ping + jf rt u "${{ env.ARTIFACT_NAME }}.zip" "dte-products/standalone/openocd/${{ github.ref_name }}/${{ env.ARTIFACT_NAME }}.zip" \ No newline at end of file