From 941f4097fe6248c53c95259163aaa815ae0c10f0 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Tue, 11 Oct 2022 18:25:36 -0400 Subject: [PATCH] Add amplitude release (#1720) Co-authored-by: Max Brunsfeld --- ...iscord_webhook.yml => release_actions.yml} | 17 +++++++++-- .gitignore | 3 +- script/amplitude_release/main.py | 30 +++++++++++++++++++ script/amplitude_release/requirements.txt | 1 + 4 files changed, 47 insertions(+), 4 deletions(-) rename .github/workflows/{discord_webhook.yml => release_actions.yml} (50%) create mode 100644 script/amplitude_release/main.py create mode 100644 script/amplitude_release/requirements.txt diff --git a/.github/workflows/discord_webhook.yml b/.github/workflows/release_actions.yml similarity index 50% rename from .github/workflows/discord_webhook.yml rename to .github/workflows/release_actions.yml index b71d451f5b..8d2788e6f0 100644 --- a/.github/workflows/discord_webhook.yml +++ b/.github/workflows/release_actions.yml @@ -1,9 +1,9 @@ on: release: types: [published] - + jobs: - message: + discord_release: runs-on: ubuntu-latest steps: - name: Discord Webhook Action @@ -19,4 +19,15 @@ jobs: ### Changelog ${{ github.event.release.body }} - ``` \ No newline at end of file + ``` + amplitude_release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10.5" + architecture: "x64" + cache: "pip" + - run: pip install -r script/amplitude_release/requirements.txt + - run: python script/amplitude_release/main.py ${{ github.event.release.tag_name }} ${{ secrets.ZED_AMPLITUDE_API_KEY }} ${{ secrets.ZED_AMPLITUDE_SECRET_KEY }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5e6963ba8b..2d721f8ad2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ /vendor/bin /assets/themes/*.json /assets/themes/internal/*.json -/assets/themes/experiments/*.json \ No newline at end of file +/assets/themes/experiments/*.json +**/venv \ No newline at end of file diff --git a/script/amplitude_release/main.py b/script/amplitude_release/main.py new file mode 100644 index 0000000000..160e40b66c --- /dev/null +++ b/script/amplitude_release/main.py @@ -0,0 +1,30 @@ +import datetime +import sys + +from amplitude_python_sdk.v2.clients.releases_client import ReleasesAPIClient +from amplitude_python_sdk.v2.models.releases import Release + + +def main(): + version = sys.argv[1] + version = version.removeprefix("v") + + api_key = sys.argv[2] + secret_key = sys.argv[3] + + current_datetime = datetime.datetime.now(datetime.timezone.utc) + current_datetime = current_datetime.strftime("%Y-%m-%d %H:%M:%S") + + release = Release( + title=version, + version=version, + release_start=current_datetime, + created_by="GitHub Release Workflow", + chart_visibility=True + ) + + ReleasesAPIClient(api_key=api_key, secret_key=secret_key).create(release) + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/script/amplitude_release/requirements.txt b/script/amplitude_release/requirements.txt new file mode 100644 index 0000000000..7ed3ea6515 --- /dev/null +++ b/script/amplitude_release/requirements.txt @@ -0,0 +1 @@ +amplitude-python-sdk==0.2.0 \ No newline at end of file