Skip to content

Commit

Permalink
endpoint to return the latest release version from the git repository
Browse files Browse the repository at this point in the history
  • Loading branch information
regisalbuquerque committed Apr 24, 2024
1 parent d422f19 commit fdb7809
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/core/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
from core.views.user import CsrfToOauth
from core.views.user import Logout
from core.views.user import UserViewSet
from core.views.git import GitAPIView
18 changes: 18 additions & 0 deletions backend/core/views/git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from rest_framework.response import Response
from rest_framework.views import APIView
import subprocess
import requests

class GitAPIView(APIView):
def get(self, request):
#version = subprocess.check_output(["git", "describe", "--tags", "--abbrev=0"])
#request on https://api.github.com/repos/linea-it/pzserver_app/releases/latest
project = 'pzserver_app'
response = requests.get(f"https://api.github.com/repos/linea-it/{project}/releases/latest")
data = response.json()
return Response({"version": data['name']})





4 changes: 4 additions & 0 deletions backend/pzserver/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
ProductViewSet,
ReleaseViewSet,
UserViewSet,
GitAPIView,
)
from django.contrib import admin
from django.urls import include, path
Expand Down Expand Up @@ -66,4 +67,7 @@
name="swagger",
),
path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
# API Git
path("api/git/", GitAPIView.as_view(), name="git"),

]
5 changes: 5 additions & 0 deletions frontend/services/git.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { api } from './api'

export const getVersion = ({ }) => {
return api.get('/api/git/').then(res => res.data)
}

0 comments on commit fdb7809

Please sign in to comment.