Skip to content

Commit 4dcf5dd

Browse files
authored
Merge pull request #124 from bparks13/main
Add GitHub Actions
2 parents 139da18 + d71de5d commit 4dcf5dd

File tree

1 file changed

+165
-0
lines changed

1 file changed

+165
-0
lines changed

.github/workflows/windows.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Windows
2+
3+
on:
4+
push:
5+
branches: [main] # NB: Runs whenever a PR is merged to main
6+
pull_request:
7+
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)
8+
release:
9+
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
10+
11+
jobs:
12+
13+
check-semver:
14+
runs-on: ubuntu-22.04
15+
if: github.event_name != 'release'
16+
steps:
17+
- name: Checkout current version
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Find previous release
23+
id: previous-release
24+
env:
25+
GH_TOKEN: ${{ github.token }}
26+
run: |
27+
echo "RELEASE_NAME=$(gh release list -L 1 --json tagName -q .[0].tagName)" >> $GITHUB_OUTPUT
28+
29+
- name: Verify release name
30+
id: verify-release
31+
if: steps.previous-release.outputs.RELEASE_NAME == ''
32+
run: |
33+
echo "No previous releases found. Skipping the semver check."
34+
exit 0
35+
36+
- name: Checkout last release version
37+
if: steps.previous-release.outputs.RELEASE_NAME != ''
38+
uses: actions/checkout@v4
39+
with:
40+
ref: ${{ steps.previous-release.outputs.RELEASE_NAME }}
41+
path: last-release
42+
sparse-checkout: |
43+
Source/OpenEphysLib.cpp
44+
sparse-checkout-cone-mode: false
45+
46+
- name: Extract Versions
47+
if: steps.previous-release.outputs.RELEASE_NAME != ''
48+
id: extract-versions
49+
run: |
50+
ls -la
51+
ls last-release -la
52+
ls last-release/Source -la
53+
cat ./last-release/Source/OpenEphysLib.cpp
54+
echo "CURRENT_VERSION=$(cat ./Source/OpenEphysLib.cpp | grep -w -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> $GITHUB_OUTPUT
55+
echo "PREVIOUS_VERSION=$(cat ./last-release/Source/OpenEphysLib.cpp | grep -w -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> $GITHUB_OUTPUT
56+
57+
- name: Setup Python
58+
if: steps.previous-release.outputs.RELEASE_NAME != ''
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: "3.10.12"
62+
63+
- name: Install semver
64+
if: steps.previous-release.outputs.RELEASE_NAME != ''
65+
run: python -m pip install semver
66+
67+
- name: Compare Versions
68+
if: steps.previous-release.outputs.RELEASE_NAME != ''
69+
run: |
70+
version_current=${{ steps.extract-versions.outputs.CURRENT_VERSION }}
71+
version_release=${{ steps.extract-versions.outputs.PREVIOUS_VERSION }}
72+
73+
echo "Current Version: $version_current"
74+
echo "Release Version: $version_release"
75+
76+
if [ ! $(python -c "import semver; print(semver.compare(\"$version_current\", \"$version_release\"))") == 1 ]; then
77+
echo "::error title=Invalid version number::Version number must be increased"
78+
exit 1
79+
fi
80+
81+
build-windows:
82+
83+
needs: [check-semver]
84+
if: always() && !failure() && !cancelled()
85+
runs-on: windows-latest
86+
outputs:
87+
PLUGIN_API: ${{ steps.setup.outputs.PLUGIN_API }}
88+
PLUGIN_VERSION: ${{ steps.setup.outputs.PLUGIN_VERSION }}
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
with:
93+
submodules: 'recursive'
94+
95+
- name: setup
96+
id: setup
97+
run: |
98+
echo "PLUGIN_VERSION=$(grep -w Source/OpenEphysLib.cpp -e 'info->libVersion' | grep -Eo "[0-9]+.[0-9]+.[0-9]+")" >> "$GITHUB_OUTPUT"
99+
cd ../..
100+
git clone https://github.com/open-ephys/plugin-GUI.git --branch main
101+
cd plugin-GUI/Build
102+
cmake -G "Visual Studio 17 2022" -A x64 ..
103+
mkdir Release && cd Release
104+
curl -L https://openephys.jfrog.io/artifactory/GUI-binaries/Libraries/open-ephys-lib-v1.0.0.zip --output open-ephys-lib.zip
105+
unzip open-ephys-lib.zip
106+
echo "PLUGIN_API=$(grep -rnw ../../Source -e '#define PLUGIN_API_VER' | grep -Eo "[0-9]*" | tail -1)" >> "$GITHUB_OUTPUT"
107+
shell: bash
108+
109+
- name: configure
110+
run: |
111+
cd Build
112+
cmake -G "Visual Studio 17 2022" -A x64 ..
113+
shell: bash
114+
115+
- name: Add msbuild to PATH
116+
uses: microsoft/setup-msbuild@v2
117+
118+
- name: build-plugin
119+
id: build-plugin
120+
run: |
121+
cd Build
122+
msbuild OE_PLUGIN_onix-source.sln -p:Configuration=Release -p:Platform=x64
123+
shell: cmd
124+
125+
- name: Collect artifact
126+
uses: actions/upload-artifact@v4
127+
if: steps.build-plugin.outcome == 'success' && always()
128+
with:
129+
name: Artifact
130+
if-no-files-found: error
131+
path: |
132+
Build/Release
133+
Build/x64
134+
135+
deploy-windows:
136+
137+
needs: [build-windows]
138+
runs-on: windows-latest
139+
if: github.event_name == 'release' && always() && !failure() && !cancelled()
140+
141+
steps:
142+
- name: Download build folder
143+
uses: actions/download-artifact@v4
144+
with:
145+
name: Artifact
146+
147+
- name: deploy
148+
env:
149+
ARTIFACTORY_ACCESS_TOKEN: ${{ secrets.ARTIFACTORY_ACCESS_TOKEN }}
150+
build_dir: "Release"
151+
liboni_dir: "x64/Release"
152+
package: ONIXSource-windows
153+
run: |
154+
plugin_api=${{ needs.build-windows.outputs.PLUGIN_API }}
155+
tag=${{ needs.build-windows.outputs.PLUGIN_VERSION }}
156+
new_plugin_ver=$tag-API$plugin_api
157+
mkdir plugins
158+
cp $build_dir/*.dll plugins
159+
mkdir shared
160+
cp $liboni_dir/*.dll shared
161+
zipfile=${package}_${new_plugin_ver}.zip
162+
powershell Compress-Archive -Path "plugins" -DestinationPath ${zipfile}
163+
powershell Compress-Archive -U -Path "shared" -DestinationPath ${zipfile}
164+
curl -H "X-JFrog-Art-Api:$ARTIFACTORY_ACCESS_TOKEN" -T $zipfile "https://openephys.jfrog.io/artifactory/ONIXSource-plugin/windows/$zipfile"
165+
shell: bash

0 commit comments

Comments
 (0)