Skip to content

Commit 72961d8

Browse files
committed
fix: cover version api call
1 parent e0e39af commit 72961d8

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import json
2+
import os
3+
4+
import http.client
5+
6+
def register_core_version(supertokens_api_key, core_version, plugin_interface_array, core_driver_array):
7+
print("Core Version: ", core_version)
8+
print("Plugin Interface Array: ", plugin_interface_array)
9+
print("Core Driver Array: ", core_driver_array)
10+
11+
conn = http.client.HTTPSConnection("api.supertokens.io")
12+
13+
payload = {
14+
"password": supertokens_api_key,
15+
"planType": "FREE",
16+
"version": core_version,
17+
"pluginInterfaces": plugin_interface_array,
18+
"coreDriverInterfaces": core_driver_array
19+
}
20+
21+
headers = {
22+
'Content-Type': 'application/json',
23+
'api-version': '0'
24+
}
25+
26+
conn.request("PUT", "/0/core", json.dumps(payload), headers)
27+
response = conn.getresponse()
28+
29+
if response.status != 200:
30+
print(f"failed core PUT API status code: {response.status}. Exiting!")
31+
exit(1)
32+
33+
conn.close()
34+
35+
36+
def read_core_version():
37+
with open('build.gradle', 'r') as file:
38+
for line in file:
39+
if 'version =' in line:
40+
return line.split('=')[1].strip().strip("'\"")
41+
raise Exception("Could not find version in build.gradle")
42+
43+
core_version = read_core_version()
44+
45+
with open('pluginInterfaceSupported.json', 'r') as fd:
46+
plugin_interface_array = json.load(fd)['versions']
47+
48+
with open('coreDriverInterfaceSupported.json', 'r') as fd:
49+
core_driver_array = json.load(fd)['versions']
50+
51+
register_core_version(
52+
supertokens_api_key=os.environ.get("SUPERTOKENS_API_KEY"),
53+
core_version=core_version,
54+
plugin_interface_array=plugin_interface_array,
55+
core_driver_array=core_driver_array
56+
)

.github/workflows/dev-tag.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,26 @@ on:
88
- 'dev-*'
99

1010
jobs:
11+
new-core-version:
12+
name: New core version
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
- name: Set up Python 3.11
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.11'
21+
- name: Run script
22+
env:
23+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
24+
run: |
25+
python .github/helpers/register-new-core-version.py
26+
1127
dependency-versions:
1228
name: Dependency Versions
1329
runs-on: ubuntu-latest
30+
needs: [new-core-version]
1431
outputs:
1532
versions: ${{ steps.result.outputs.versions }}
1633
steps:

0 commit comments

Comments
 (0)