Skip to content

Commit 61519c1

Browse files
authored
Merge pull request #540 from cmu-delphi/sgratzl/version
add version endpoint
2 parents 2df8d63 + a7e566f commit 61519c1

File tree

5 files changed

+61
-7
lines changed

5 files changed

+61
-7
lines changed

.bumpversion.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[bumpversion]
2+
current_version = 0.1.0
3+
commit = False
4+
tag = False
5+
6+
[bumpversion:file:src/server/_config.py]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Create Delphi Epidata Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
versionName:
6+
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)'
7+
required: true
8+
default: patch
9+
jobs:
10+
create_release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v2
15+
with:
16+
ref: main
17+
ssh-key: ${{ secrets.CMU_DELPHI_DEPLOY_MACHINE_SSH }}
18+
- name: Reset dev branch
19+
run: |
20+
git fetch origin dev:dev
21+
git reset --hard main
22+
- name: Set up Python 3.8
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: 3.8
26+
- name: Change version number
27+
id: version
28+
run: |
29+
python -m pip install bump2version
30+
echo -n "::set-output name=next_tag::"
31+
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
32+
- name: Create pull request into prod
33+
uses: peter-evans/create-pull-request@v3
34+
with:
35+
branch: release/delphi-epidata-${{ steps.version.outputs.next_tag }}
36+
commit-message: 'chore: release delphi-epidata ${{ steps.version.outputs.next_tag }}'
37+
base: main
38+
title: Release Delphi Epidata ${{ steps.version.outputs.next_tag }}
39+
labels: chore
40+
reviewers: krivard
41+
assignees: krivard
42+
body: |
43+
Releasing Delphi Epidata ${{ steps.version.outputs.next_tag }}.

requirements.dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ black>=20.8b1
33
sqlalchemy-stubs>=0.3
44
mypy>=0.790
55
pytest
6+
bump2version

src/server/_config.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55

66
load_dotenv()
77

8+
VERSION = "0.1.0"
89

910
MAX_RESULTS = int(10e6)
1011
MAX_COMPATIBILITY_RESULTS = int(3650)
1112

1213
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite:///test.db")
13-
SQLALCHEMY_ENGINE_OPTIONS = json.loads(
14-
os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}")
15-
)
16-
SECRET = os.environ.get("FLASK_SECRET", 'secret')
17-
URL_PREFIX = os.environ.get('FLASK_PREFIX', '/')
14+
SQLALCHEMY_ENGINE_OPTIONS = json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}"))
15+
SECRET = os.environ.get("FLASK_SECRET", "secret")
16+
URL_PREFIX = os.environ.get("FLASK_PREFIX", "/")
1817

1918
AUTH = {
2019
"twitter": os.environ.get("SECRET_TWITTER"),

src/server/main.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import logging
33
from typing import Dict, Callable
44

5-
from flask import request, send_file, Response, send_from_directory
5+
from flask import request, send_file, Response, send_from_directory, jsonify
66

7-
from ._config import URL_PREFIX
7+
from ._config import URL_PREFIX, VERSION
88
from ._common import app, set_compatibility_mode
99
from ._exceptions import MissingOrWrongSourceException
1010
from .endpoints import endpoints
@@ -39,6 +39,11 @@ def send_index_file():
3939
return send_file(pathlib.Path(__file__).parent / "index.html")
4040

4141

42+
@app.route(f"{URL_PREFIX}/version")
43+
def send_version():
44+
return jsonify(dict(version=VERSION))
45+
46+
4247
@app.route(f"{URL_PREFIX}/lib/<path:path>")
4348
def send_lib_file(path: str):
4449
return send_from_directory(pathlib.Path(__file__).parent / "lib", path)

0 commit comments

Comments
 (0)