Skip to content

Commit ebeb635

Browse files
committed
fix: create new plugin version
1 parent e665994 commit ebeb635

File tree

2 files changed

+95
-15
lines changed

2 files changed

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

.github/workflows/dev-tag.yml

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ on:
88
- 'dev-*'
99

1010
jobs:
11+
dependency-versions:
12+
name: Dependency Versions
13+
runs-on: ubuntu-latest
14+
outputs:
15+
versions: ${{ steps.result.outputs.versions }}
16+
branches: ${{ steps.result.outputs.branches }}
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: supertokens/get-core-dependencies-action@main
20+
with:
21+
run-for: PR
22+
id: result
1123
new-core-version:
1224
name: New core version
1325
runs-on: ubuntu-latest
26+
needs: [dependency-versions]
1427
steps:
1528
- name: Checkout
1629
uses: actions/checkout@v4
@@ -23,26 +36,42 @@ jobs:
2336
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
2437
run: |
2538
python .github/helpers/register-new-core-version.py
26-
27-
dependency-versions:
28-
name: Dependency Versions
29-
runs-on: ubuntu-latest
30-
outputs:
31-
versions: ${{ steps.result.outputs.versions }}
32-
steps:
33-
- uses: actions/checkout@v4
34-
- uses: supertokens/get-core-dependencies-action@main
35-
with:
36-
run-for: PR
37-
id: result
39+
new-plugin-versions:
40+
name: New plugin versions
41+
runs-on: ubuntu-latest
42+
needs: [dependency-versions]
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
plugin:
47+
- postgresql
48+
# no longer supported
49+
# - mysql
50+
# - mongodb
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
with:
57+
path: ./supertokens-plugin
58+
repository: supertokens/supertokens-${{ matrix.plugin }}-plugin
59+
ref: ${{ fromJson(needs.dependency-versions.outputs.branches)[matrix.plugin] }}
60+
- name: Run script
61+
env:
62+
SUPERTOKENS_API_KEY: ${{ secrets.SUPERTOKENS_API_KEY }}
63+
PLUGIN_NAME: ${{ matrix.plugin }}
64+
run: |
65+
cd supertokens-plugin
66+
python ../.github/helpers/register-new-plugin-version.py
3867
unit-tests:
3968
name: Run unit tests
40-
needs: [new-core-version]
69+
needs: [new-core-version, new-plugin-versions]
4170
uses: ./.github/workflows/unit-test.yml
4271
wait-for-docker:
4372
name: Wait for Docker
4473
runs-on: ubuntu-latest
45-
needs: [new-core-version]
74+
needs: [new-core-version, new-plugin-versions]
4675
outputs:
4776
tag: ${{ steps.set_tag.outputs.TAG }}
4877
steps:
@@ -57,7 +86,6 @@ jobs:
5786
SHA: ${{ github.sha }}
5887
run: |
5988
python .github/helpers/wait-for-docker.py
60-
6189
- name: set tag
6290
id: set_tag
6391
run: |

0 commit comments

Comments
 (0)