Skip to content

Add liboni as submodule #79

Add liboni as submodule

Add liboni as submodule #79

Workflow file for this run

name: mac
on:
push:
branches: [main] # NB: Runs whenever a PR is merged to main
pull_request:
branches: [main] # NB: Runs when a PR to main is opened. This can be expanded to run when PRs are opened to other branches (i.e., testing-juce8)
release:
types: [published] # NB: Runs whenever a new release is created. Releases are based on tags, but are separate in that a tag can be created without a concurrent release
jobs:
check-semver:
runs-on: ubuntu-22.04
if: github.event_name != 'release'
steps:
- name: Checkout current version
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find previous release
id: previous-release
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "RELEASE_NAME=$(gh release list -L 1 --json tagName -q .[0].tagName)" >> $GITHUB_OUTPUT
- name: Checkout last release version
uses: actions/checkout@v4
with:
ref: ${{ steps.previous-release.outputs.RELEASE_NAME }}
path: last-release
sparse-checkout: |
Source/OpenEphysLib.cpp
sparse-checkout-cone-mode: false
- name: Extract Versions
id: extract-versions
run: |
ls -la
ls last-release -la
ls last-release/Source -la
cat ./last-release/Source/OpenEphysLib.cpp
echo "CURRENT_VERSION=$(cat ./Source/OpenEphysLib.cpp | grep -w -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> $GITHUB_OUTPUT
echo "PREVIOUS_VERSION=$(cat ./last-release/Source/OpenEphysLib.cpp | grep -w -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> $GITHUB_OUTPUT
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10.12"
- name: Install semver
run: python -m pip install semver
- name: Compare Versions
run: |
version_current=${{ steps.extract-versions.outputs.CURRENT_VERSION }}
version_release=${{ steps.extract-versions.outputs.PREVIOUS_VERSION }}
echo "Current Version: $version_current"
echo "Release Version: $version_release"
if [ ! $(python -c "import semver; print(semver.compare(\"$version_current\", \"$version_release\"))") == 1 ]; then
echo "::error title=Invalid version number::Version number must be increased"
exit 1
fi
build-mac:
needs: [check-semver]
if: always() && !failure() && !cancelled()
runs-on: macos-latest
outputs:
PLUGIN_API: ${{ steps.setup.outputs.PLUGIN_API }}
PLUGIN_VERSION: ${{ steps.setup.outputs.PLUGIN_VERSION }}
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: setup
id: setup
run: |
echo "PLUGIN_VERSION=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> "$GITHUB_OUTPUT"
cd ../..
git clone https://github.com/open-ephys/plugin-GUI.git --branch main
cd plugin-GUI/Build && cmake -G "Xcode" ..
echo "PLUGIN_API=$(grep -rnw ../Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1)" >> "$GITHUB_OUTPUT"
- name: build
id: build
run: |
cd Build
cmake -G "Xcode" ..
xcodebuild -configuration Release
- name: Collect artifact
uses: actions/upload-artifact@v4
if: steps.build.outcome == 'success' && always()
with:
name: Artifact
if-no-files-found: error
path: |
Build
Resources
deploy-mac:
needs: [build-mac]
runs-on: macos-latest
if: github.event_name == 'release' && always() && !failure() && !cancelled()
steps:
- name: Download build folder
uses: actions/download-artifact@v4
with:
name: Artifact
- name: codesign_deploy
env:
ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
MACOS_CERTIFICATE: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
MACOS_CERTIFICATE_PWD: ${{ secrets.BUILD_CERTIFICATE_PWD }}
MACOS_CERTIFICATE_NAME: ${{ secrets.BUILD_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.PROD_MACOS_CI_KEYCHAIN_PWD }}
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_APPLE_ID }}
PROD_MACOS_NOTARIZATION_TEAM_ID: ${{ secrets.PROD_MACOS_NOTARIZATION_TEAM_ID }}
PROD_MACOS_NOTARIZATION_PWD: ${{ secrets.PROD_MACOS_NOTARIZATION_PWD }}
build_dir: "Build/Release"
package: AcquisitionBoard-mac
run: |
plugin_api=${{ needs.build-mac.outputs.PLUGIN_API }}
tag=${{ needs.build-mac.outputs.PLUGIN_VERSION }}
new_plugin_ver=$tag-API$plugin_api
mkdir plugins
cp -r $build_dir/*.bundle plugins
mkdir shared
cp -r Resources/libokFrontPanel.1.dylib shared
cp Resources/*.bit shared
cp -r Build/lib/*.dylib shared
# Turn our base64-encoded certificate back to a regular .p12 file
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
# We need to create a new keychain, otherwise using the certificate will prompt
# with a UI dialog asking for the certificate password, which we can't
# use in a headless CI environment
security create-keychain -p $MACOS_CI_KEYCHAIN_PWD build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p $MACOS_CI_KEYCHAIN_PWD build.keychain
security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CI_KEYCHAIN_PWD build.keychain
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" -v plugins/acquisition-board.bundle --deep --strict --timestamp --options=runtime
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" -v shared/liboni.dylib --deep --strict --timestamp --options=runtime
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" -v shared/libonidriver_ft600.dylib --deep --strict --timestamp --options=runtime
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" -v shared/libokFrontPanel.1.dylib --deep --strict --timestamp --options=runtime
/usr/bin/codesign -dv --verbose=4 plugins/acquisition-board.bundle
# Store the notarization credentials so that we can prevent a UI password dialog from blocking the CI
echo "Create keychain profile"
xcrun notarytool store-credentials "notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
# We can't notarize an app bundle directly, but we need to compress it as an archive.
# Therefore, we create a zip file containing our app bundle, so that we can send it to the
# notarization service
echo "Creating temp notarization archive"
/usr/bin/ditto -c -k --sequesterRsrc --keepParent plugins/acquisition-board.bundle acquisition-board.zip
# Here we send the notarization request to the Apple's Notarization service, waiting for the result.
# This typically takes a few seconds inside a CI environment, but it might take more depending on the App
# characteristics. Visit the Notarization docs for more information and strategies on how to optimize it if
# you're curious
echo "Notarize app"
xcrun notarytool submit "acquisition-board.zip" --keychain-profile "notarytool-profile" --wait
# Finally, we need to "attach the staple" to our executable, which will allow our app to be
# validated by macOS even when an internet connection is not available.
echo "Attach staple"
rm -r plugins/*
/usr/bin/ditto -x -k acquisition-board.zip plugins
xcrun stapler staple plugins/acquisition-board.bundle
spctl -vvv --assess --type exec plugins/acquisition-board.bundle
zipfile=${package}_${new_plugin_ver}.zip
mkdir temp_dir
cp -R plugins shared temp_dir
/usr/bin/ditto -c -k --sequesterRsrc temp_dir $zipfile
curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/AcquisitionBoard-plugin/mac/$zipfile"