Skip to content

Commit

Permalink
✨(scripts) adapts release script
Browse files Browse the repository at this point in the history
Adapts the release script after moving
the deployment part to a new repository.
  • Loading branch information
sdemagny committed Jan 21, 2025
1 parent 615d589 commit 56f4b25
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to

## [Unreleased]

### Changed

- ✨(scripts) adapts release script after moving the deployment part

## [1.10.0] - 2025-01-21

### Added
Expand Down
83 changes: 55 additions & 28 deletions scripts/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@ def update_files(version):
with open(path, 'w+') as file:
file.writelines(lines)

# helm files
sys.stdout.write("Update helm files...\n")
for env in ["preprod", "production"]:
path = f"src/helm/env.d/{env}/values.desk.yaml.gotmpl"
with open(path, 'r') as file:
lines = file.readlines()
for index, line in enumerate(lines):
if "tag:" in line:
lines[index] = re.sub(r'\"(.*?)\"', f'"v{version}"', line)
with open(path, 'w+') as file:
file.writelines(lines)

# frontend package.json
sys.stdout.write("Update package.json...\n")
files_to_modify = []
Expand All @@ -55,6 +43,16 @@ def update_files(version):
return


def update_helm_files(path):
sys.stdout.write("Update helm files...\n")
with open(path, 'r') as file:
lines = file.readlines()
for index, line in enumerate(lines):
if "tag:" in line:
lines[index] = re.sub(r'\"(.*?)\"', f'"v{version}"', line)
with open(path, 'w+') as file:
file.writelines(lines)

def update_changelog(path, version):
"""Update changelog file with release info
"""
Expand All @@ -77,7 +75,38 @@ def update_changelog(path, version):
file.writelines(lines)


def prepare_release(version, kind):
def deployment_part(version, kind):
# Move to lasuite-deploiement repository
try:
os.chdir('../lasuite-deploiement')
except FileNotFoundError:
msg = "[Error] You must have a clone of https://github.com/numerique-gouv/lasuite-deploiement"
sys.stdout.write(f"\033[1;31m {msg} \x1b[0m")
msg = "Please clone it and re-run script with option --only-deployment-part"
sys.stdout.write(f"\033[0;32m {msg} \x1b[0m")
else:
run_command("git checkout main", shell=True)
run_command("git pull", shell=True)
deployment_branch = f"regie/{version}/preprod/"
run_command(f"git checkout -b {deployment_branch}", shell=True)
run_command("git pull --rebase origin main", shell=True)
path = f"manifests/regie/env.d/preprod/values.desk.yaml.gotmpl"
update_helm_files(path)
run_command(f"git add {path}")
message = f"""🔖({RELEASE_KINDS[kind]}) release version {version}"""
run_command(f"git commit -m '{message}'", shell=True)
confirm = input(
f"\nNEXT COMMAND on lasuite-deploiement repository: \n>> git push origin {deployment_branch}\nContinue ? (y,n)")
if confirm == 'y':
sys.stdout.write(f"fake -> git push origin {deployment_branch}")
#run_command(f"git push origin {deployment_branch}", shell=True)
sys.stdout.write(f"""
PLEASE DO THE FOLLOWING INSTRUCTIONS:
--> Please submit PR and merge code to main""")
sys.stdout.write(f"""
--> Now please generate release on github interface for the current tag v{version}""")

def project_part(version, kind):
sys.stdout.write('Let\'s go to create branch to release\n')
branch_to_release = f"release/{version}"
run_command(f"git checkout -b {branch_to_release}", shell=True)
Expand All @@ -90,25 +119,21 @@ def prepare_release(version, kind):
run_command("git add src/", shell=True)
message = f"""🔖({RELEASE_KINDS[kind]}) release version {version}
Update all version files and changelog for {RELEASE_KINDS[kind]} release."""
Update all version files and changelog for {RELEASE_KINDS[kind]} release."""
run_command(f"git commit -m '{message}'", shell=True)
confirm = input(f"\nNEXT COMMAND: \n>> git push origin {branch_to_release}\nContinue ? (y,n) ")
if confirm == 'y':
run_command(f"git push origin {branch_to_release}", shell=True)
sys.stdout.write(f"""
PLEASE DO THE FOLLOWING INSTRUCTIONS:
--> Please submit PR and merge code to main
--> Then do:
>> git checkout main
>> git pull
>> git tag v{version}
>> git push origin v{version}
--> Please check and wait for the docker image v{version} to be published here: https://hub.docker.com/r/lasuite/people-backend/tags and https://hub.docker.com/r/lasuite/people-frontend/tags
>> git tag -d preprod
>> git tag preprod
>> git push -f origin preprod
--> Now please generate release on github interface for the current tag v{version}
""")
PLEASE DO THE FOLLOWING INSTRUCTIONS:
--> Please submit PR and merge code to main
--> Then do:
>> git checkout main
>> git pull
>> git tag v{version}
>> git push origin v{version}
--> Please check and wait for the docker image v{version} to be published here: https://hub.docker.com/r/lasuite/people-backend/tags and https://hub.docker.com/r/lasuite/people-frontend/tags
""")


if __name__ == "__main__":
Expand All @@ -117,4 +142,6 @@ def prepare_release(version, kind):
version = input("Enter your release version:")
while kind not in RELEASE_KINDS:
kind = input("Enter kind of release (p:patch, m:minor, mj:major):")
prepare_release(version, kind)
if "--only-deployment-part" not in sys.argv:
project_part(version, kind)
deployment_part(version, kind)

0 comments on commit 56f4b25

Please sign in to comment.