Skip to content

Commit d3436b5

Browse files
authored
Merge pull request #264 from open-ephys/issue-250
Add step to check semantic version
2 parents 67f250d + 53728df commit d3436b5

File tree

3 files changed

+56
-3
lines changed

3 files changed

+56
-3
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,49 @@ jobs:
2424
id: setup-build
2525
run: echo "build-suffix=${{ github.event_name == 'push' && env.CiRunPushSuffix || github.event_name == 'pull_request' && env.CiRunPullSuffix || null }}" >> "$GITHUB_OUTPUT"
2626

27+
check-semver:
28+
runs-on: ubuntu-latest
29+
if: github.event_name == 'pull_request'
30+
steps:
31+
- name: Checkout current version
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Find previous release
37+
id: previous-release
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
echo "RELEASE_NAME=$(gh release list -L 1 --json tagName -q .[0].tagName)" >> $GITHUB_OUTPUT
42+
- name: Checkout last release version
43+
uses: actions/checkout@v4
44+
with:
45+
ref: ${{ steps.previous-release.outputs.RELEASE_NAME }}
46+
path: last-release
47+
sparse-checkout: |
48+
Directory.Build.props
49+
sparse-checkout-cone-mode: false
50+
51+
- name: Extract Versions
52+
id: extract-versions
53+
run: |
54+
echo "CURRENT_VERSION=$(cat ./Directory.Build.props | grep -Po '(?<=VersionPrefix>).*(?=</VersionPrefix>)')" >> $GITHUB_OUTPUT
55+
echo "PREVIOUS_VERSION=$(cat ./last-release/Directory.Build.props | grep -Po '(?<=VersionPrefix>).*(?=</VersionPrefix>)')" >> $GITHUB_OUTPUT
56+
- name: Setup Python
57+
uses: actions/setup-python@v5
58+
with:
59+
python-version: "3.10.12"
60+
61+
- name: Install semver
62+
run: python -m pip install semver
63+
64+
- name: Compare Versions
65+
run: .github/workflows/compare_version_numbers.sh
66+
2767
build:
28-
needs: [setup]
68+
needs: [setup, check-semver]
69+
if: always() && !failure() && !cancelled()
2970
strategy:
3071
fail-fast: false
3172
matrix:
@@ -71,7 +112,7 @@ jobs:
71112
permissions:
72113
packages: write
73114
needs: [build]
74-
if: github.event_name == 'push' || github.event_name == 'release'
115+
if: (github.event_name == 'push' || github.event_name == 'release') && always() && !failure() && !cancelled()
75116
steps:
76117
- name: Setup .NET
77118
uses: actions/setup-dotnet@v4
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /bin/bash
2+
3+
version_current=$(cat ./Directory.Build.props | grep -Po '(?<=VersionPrefix>).*(?=</VersionPrefix>)')
4+
version_release=$(cat ./last-release/Directory.Build.props | grep -Po '(?<=VersionPrefix>).*(?=</VersionPrefix>)')
5+
6+
echo "Current Version: $version_current"
7+
echo "Release Version: $version_release"
8+
9+
if [ ! $(python -c "import semver; print(semver.compare(\"$version_current\", \"$version_release\"))") == 1 ]; then
10+
echo "::error title=Invalid version number::Version number must be increased"
11+
exit 1
12+
fi

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1414
<UseArtifactsOutput>true</UseArtifactsOutput>
1515
<PackageIcon>icon.png</PackageIcon>
16-
<VersionPrefix>0.2.0</VersionPrefix>
16+
<VersionPrefix>0.3.0</VersionPrefix>
1717
<VersionSuffix></VersionSuffix>
1818
<LangVersion>10.0</LangVersion>
1919
<Features>strict</Features>

0 commit comments

Comments
 (0)