Skip to content

Commit

Permalink
Build workflow for macOS (#36)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
emmet-horgan authored Aug 27, 2024
1 parent 03af81f commit 2f82532
Show file tree
Hide file tree
Showing 3 changed files with 391 additions and 0 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/build_debug_macos.yml
Original file line number Diff line number Diff line change
@@ -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
142 changes: 142 additions & 0 deletions .github/workflows/release_adi_macos.yml
Original file line number Diff line number Diff line change
@@ -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"
133 changes: 133 additions & 0 deletions .github/workflows/snapshot_adi_macos.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 2f82532

Please sign in to comment.