From cce1de2ce8cfc1a362b5862b48a5c8b21584024f Mon Sep 17 00:00:00 2001 From: bparks13 Date: Fri, 12 Dec 2025 11:36:11 -0500 Subject: [PATCH 1/2] Update GitHub Actions to check for semantic version, and only upload new package on release --- .github/workflows/linux.yml | 97 +++++++++++++++++++++++++++++++++-- .github/workflows/mac.yml | 93 ++++++++++++++++++++++++++++++++- .github/workflows/windows.yml | 97 ++++++++++++++++++++++++++++++++++- 3 files changed, 282 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 9196412..e482165 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -4,6 +4,9 @@ on: push: branches: [main] pull_request: + branches: [main] + release: + types: [published] env: ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} @@ -11,7 +14,74 @@ env: package: EphysSocket-linux 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: Verify release name + id: verify-release + if: steps.previous-release.outputs.RELEASE_NAME == '' + run: | + echo "No previous releases found. Skipping the semver check." + exit 0 + + - name: Checkout last release version + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + id: extract-versions + run: | + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + uses: actions/setup-python@v5 + with: + python-version: "3.10.12" + + - name: Install semver + if: steps.previous-release.outputs.RELEASE_NAME != '' + run: python -m pip install semver + + - name: Compare Versions + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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-linux: + needs: [check-semver] + if: always() && !failure() && !cancelled() runs-on: [ubuntu-22.04] steps: @@ -24,17 +94,38 @@ jobs: cd ../.. git clone https://github.com/open-ephys/plugin-GUI.git --branch main sudo ./plugin-GUI/Resources/Scripts/install_linux_dependencies.sh - cd plugin-GUI/Build && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. + cd plugin-GUI/$build_dir && cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. - name: build id: build run: | - cd Build + cd $build_dir cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. make + + - name: Collect artifact + uses: actions/upload-artifact@v4 + if: steps.build.outcome == 'success' && always() + with: + name: Artifact + if-no-files-found: error + path: | + $build_dir + + deploy-linux: + + needs: [build-linux] + runs-on: ubuntu-22.04 + if: github.event_name == 'release' && always() && !failure() && !cancelled() + + steps: + - name: Download build folder + uses: actions/download-artifact@v4 + with: + name: Artifact + path: $build_dir - name: deploy - if: github.ref == 'refs/heads/main' && steps.build.outcome == 'success' run: | plugin_api=$(grep -rnw ../../plugin-GUI/Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1) tag=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+") diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 8f6a03b..448161a 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -4,6 +4,9 @@ on: push: branches: [main] pull_request: + branches: [main] + release: + types: [published] env: ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} @@ -11,7 +14,74 @@ env: package: EphysSocket-mac 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: Verify release name + id: verify-release + if: steps.previous-release.outputs.RELEASE_NAME == '' + run: | + echo "No previous releases found. Skipping the semver check." + exit 0 + + - name: Checkout last release version + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + id: extract-versions + run: | + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + uses: actions/setup-python@v5 + with: + python-version: "3.10.12" + + - name: Install semver + if: steps.previous-release.outputs.RELEASE_NAME != '' + run: python -m pip install semver + + - name: Compare Versions + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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] steps: @@ -31,8 +101,29 @@ jobs: 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_dir + + 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 + path: $build_dir + - name: deploy - if: github.ref == 'refs/heads/main' && steps.build.outcome == 'success' env: MACOS_CERTIFICATE: ${{ secrets.BUILD_CERTIFICATE_BASE64 }} MACOS_CERTIFICATE_PWD: ${{ secrets.BUILD_CERTIFICATE_PWD }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index deb2c94..ba4e0ba 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -4,6 +4,9 @@ on: push: branches: [main] pull_request: + branches: [main] + release: + types: [published] env: ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }} @@ -11,7 +14,78 @@ env: package: EphysSocket-windows 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: Verify release name + id: verify-release + if: steps.previous-release.outputs.RELEASE_NAME == '' + run: | + echo "No previous releases found. Skipping the semver check." + exit 0 + + - name: Checkout last release version + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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 + if: steps.previous-release.outputs.RELEASE_NAME != '' + uses: actions/setup-python@v5 + with: + python-version: "3.10.12" + + - name: Install semver + if: steps.previous-release.outputs.RELEASE_NAME != '' + run: python -m pip install semver + + - name: Compare Versions + if: steps.previous-release.outputs.RELEASE_NAME != '' + 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-windows: + needs: [check-semver] + if: always() && !failure() && !cancelled() runs-on: [windows-latest] steps: @@ -45,8 +119,29 @@ jobs: msbuild INSTALL.vcxproj -p:Configuration=Release -p:Platform=x64 shell: cmd + - name: Collect artifact + uses: actions/upload-artifact@v4 + if: steps.build.outcome == 'success' && always() + with: + name: Artifact + if-no-files-found: error + path: | + $build_dir + + deploy-windows: + + needs: [build-windows] + runs-on: windows-latest + if: github.event_name == 'release' && always() && !failure() && !cancelled() + + steps: + - name: Download build folder + uses: actions/download-artifact@v4 + with: + name: Artifact + path: $build_dir + - name: deploy - if: github.ref == 'refs/heads/main' && steps.build.outcome == 'success' run: | plugin_api=$(grep -rnw ../../plugin-GUI/Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1) tag=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+") From cf8b7fa180de06ca8da58478f46a3b646bc7a532 Mon Sep 17 00:00:00 2001 From: bparks13 Date: Fri, 12 Dec 2025 11:39:48 -0500 Subject: [PATCH 2/2] Correct environment call --- .github/workflows/linux.yml | 5 ++--- .github/workflows/mac.yml | 5 ++--- .github/workflows/windows.yml | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e482165..fb8f610 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -109,8 +109,7 @@ jobs: with: name: Artifact if-no-files-found: error - path: | - $build_dir + path: ${{ env.build_dir }} deploy-linux: @@ -123,7 +122,7 @@ jobs: uses: actions/download-artifact@v4 with: name: Artifact - path: $build_dir + path: ${{ env.build_dir }} - name: deploy run: | diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 448161a..cfeec07 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -107,8 +107,7 @@ jobs: with: name: Artifact if-no-files-found: error - path: | - $build_dir + path: ${{ env.build_dir }} deploy-mac: @@ -121,7 +120,7 @@ jobs: uses: actions/download-artifact@v4 with: name: Artifact - path: $build_dir + path: ${{ env.build_dir }} - name: deploy env: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ba4e0ba..71e2c22 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -125,8 +125,7 @@ jobs: with: name: Artifact if-no-files-found: error - path: | - $build_dir + path: ${{ env.build_dir }} deploy-windows: @@ -139,7 +138,7 @@ jobs: uses: actions/download-artifact@v4 with: name: Artifact - path: $build_dir + path: ${{ env.build_dir }} - name: deploy run: |