From 46937ddc0133ab5d56af1e04e05b8717af7517c6 Mon Sep 17 00:00:00 2001 From: Jingru923 <47444880+Jingru923@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:15:40 +0200 Subject: [PATCH] only release if branch stars with v20 (#1411) Fixes #1404 --- .../Ribasim_Ribasim_MakeQgisPlugin.xml | 10 --- .../Ribasim_Linux_TestRibasimApi.xml | 4 +- .../Ribasim_Linux_TestRibasimCli.xml | 4 +- .../Ribasim_Windows_TestRibasimApi.xml | 3 +- .../Ribasim_Windows_TestRibasimCli.xml | 3 +- utils/github-release.py | 62 ++++++++++++------- 6 files changed, 44 insertions(+), 42 deletions(-) diff --git a/.teamcity/Ribasim/buildTypes/Ribasim_Ribasim_MakeQgisPlugin.xml b/.teamcity/Ribasim/buildTypes/Ribasim_Ribasim_MakeQgisPlugin.xml index d770446c1..f40eff904 100644 --- a/.teamcity/Ribasim/buildTypes/Ribasim_Ribasim_MakeQgisPlugin.xml +++ b/.teamcity/Ribasim/buildTypes/Ribasim_Ribasim_MakeQgisPlugin.xml @@ -27,16 +27,6 @@ zip -r ribasim_qgis.zip ribasim_qgis]]> - - - - - -+:v*]]> - - - - diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml index 36efad6af..57421a5a8 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimApi.xml @@ -51,9 +51,7 @@ pixi run test-ribasim-api]]> - -+:v* -+pr:target=main]]> + ]]> diff --git a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml index c8706f2aa..395cb5bab 100644 --- a/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml +++ b/.teamcity/Ribasim_Linux/buildTypes/Ribasim_Linux_TestRibasimCli.xml @@ -51,9 +51,7 @@ pixi run test-ribasim-cli]]> - -+:v* -+pr:release*]]> + ]]> diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml index f5be3f027..5683f3182 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimApi.xml @@ -38,8 +38,7 @@ - -+:v*]]> + ]]> diff --git a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml index 643fa02a4..035f583e2 100644 --- a/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml +++ b/.teamcity/Ribasim_Windows/buildTypes/Ribasim_Windows_TestRibasimCli.xml @@ -38,8 +38,7 @@ - -+:v*]]> + ]]> diff --git a/utils/github-release.py b/utils/github-release.py index c0d3da74e..0b78a30f4 100644 --- a/utils/github-release.py +++ b/utils/github-release.py @@ -1,24 +1,42 @@ import subprocess -# Get the name of the currently checked out tag -tag_name = subprocess.check_output( - ["git", "describe", "--tags", "--exact-match"], text=True -).strip() - - -print(f"Currently checked out tag: {tag_name}") - -# Create a release using gh -subprocess.check_call( - [ - "gh", - "release", - "create", - tag_name, - "--generate-notes", - "ribasim_cli_linux.zip", - "ribasim_cli_windows.zip", - "ribasim_qgis.zip", - "generated_testmodels.zip", - ] -) + +def current_git_branch(): + result = subprocess.run( + ["git", "rev-parse", "--abbrev-ref", "HEAD"], + capture_output=True, + text=True, + check=True, + ) + return result.stdout.strip() + + +def main(): + # Get the name of the currently checked out tag + tag_name = subprocess.check_output( + ["git", "describe", "--tags", "--exact-match"], text=True + ).strip() + + print(f"Currently checked out tag: {tag_name}") + + # Create a release using gh + subprocess.check_call( + [ + "gh", + "release", + "create", + tag_name, + "--generate-notes", + "ribasim_cli_linux.zip", + "ribasim_cli_windows.zip", + "ribasim_qgis.zip", + "generated_testmodels.zip", + ] + ) + + +if __name__ == "__main__": + if current_git_branch().startswith("v20"): + main() + else: + print("Branch doesn't start with 'v20', no release made.")