Skip to content

Commit 850e710

Browse files
committed
Merge branch 'master' of github.com:mmb-irb/MDDB-REST-API
2 parents f6c2c85 + de636b0 commit 850e710

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Version Check
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
check-version:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0 # Fetch all history for all tags
20+
21+
- name: Get latest tag
22+
id: get_tag
23+
run: |
24+
# Get the latest tag
25+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
26+
27+
if [ -z "$LATEST_TAG" ]; then
28+
echo "No tags found in repository"
29+
echo "latest_tag=none" >> $GITHUB_OUTPUT
30+
else
31+
echo "Latest tag: $LATEST_TAG"
32+
# Remove 'v' prefix if present
33+
TAG_VERSION=${LATEST_TAG#v}
34+
echo "latest_tag=$TAG_VERSION" >> $GITHUB_OUTPUT
35+
fi
36+
37+
- name: Get package.json version
38+
id: get_version
39+
run: |
40+
PACKAGE_VERSION=$(node -p "require('./package.json').version")
41+
echo "Package version: $PACKAGE_VERSION"
42+
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
43+
44+
- name: Compare versions
45+
run: |
46+
LATEST_TAG="${{ steps.get_tag.outputs.latest_tag }}"
47+
PACKAGE_VERSION="${{ steps.get_version.outputs.package_version }}"
48+
49+
if [ "$LATEST_TAG" = "$PACKAGE_VERSION" ]; then
50+
echo "✅ Version match! package.json ($PACKAGE_VERSION) matches latest tag ($LATEST_TAG)"
51+
else
52+
echo "❌ Version mismatch!"
53+
echo " package.json version: $PACKAGE_VERSION"
54+
echo " Latest git tag: $LATEST_TAG"
55+
echo ""
56+
echo "Please update package.json version to match the tag or create a new tag."
57+
exit 1
58+
fi

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "MoDEL-CNS_REST_API",
3-
"version": "0.0.1",
3+
"version": "0.0.4",
44
"description": "MoDEL-CNS REST API",
55
"main": "index.js",
66
"private": true,
@@ -23,7 +23,7 @@
2323
},
2424
"repository": {
2525
"type": "git",
26-
"url": "[git@mmb.pcb.ub.es:22123]:aluciani/MoDEL-CNS_REST_API.git"
26+
"url": "git@github.com:mmb-irb/MDDB-REST-API.git"
2727
},
2828
"keywords": [
2929
"model",

src/server/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const swStats = require('swagger-stats');
1212

1313
const routes = require('../routes');
1414
//const getCustomTimeout = require('../middlewares/custom-timeout');
15+
const { version } = require('../../package.json');
1516

1617
// Auxiliar functions
1718
const { getHost } = require('../utils/auxiliar-functions');
@@ -70,7 +71,8 @@ app.get('/rest', (_, res) =>
7071
'api versions': ['v1', 'current'],
7172
'current version': 'v1',
7273
documentation: 'docs',
73-
'federated specification': 'spec'
74+
'federated specification': 'spec',
75+
'software version': version,
7476
}),
7577
);
7678

0 commit comments

Comments
 (0)