diff --git a/.github/workflows/TC-version-update.yml b/.github/workflows/TC-version-update.yml new file mode 100644 index 00000000..5327b09e --- /dev/null +++ b/.github/workflows/TC-version-update.yml @@ -0,0 +1,39 @@ +name: TC version update + +# Controls when the action will run. +on: + push: + branches: + - 'TC-*' + - 'TC_*' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# setup python and run script +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout repo content + uses: actions/checkout@v2 # checkout the repository content + + - name: setup python + uses: actions/setup-python@v4 + with: + python-version: '3.10' # install the python version needed + + - name: install python packages + run: | + python -m pip install --upgrade pip + pip install pyyaml + + - name: execute py script # run main.py + run: python ./scripts/release_publish.py -b + + - name: Add & Commit + uses: EndBug/add-and-commit@v9 + with: + committer_name: GitHub Actions Bot + committer_email: ActionBot@github.com + message: auto-generated file update of TC version by GitHub Actions \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d5da5dc..ad0d843d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: # Java and .NET are already installed on ubuntu-latest - name: Firely.Terminal (GitHub Actions) - uses: FirelyTeam/firely-terminal-pipeline@v0.3.5 + uses: FirelyTeam/firely-terminal-pipeline@v0.4.1 with: PATH_TO_CONFORMANCE_RESOURCES: Resources/fsh-generated/resources/ #PATH_TO_EXAMPLES: Examples @@ -42,6 +42,7 @@ jobs: SIMPLIFIER_PASSWORD: ${{ secrets.SIMPLIFIER_PASSWORD }} SUSHI_ENABLED: true SUSHI_OPTIONS: Resources/ + SUSHI_VERSION: 3.9.0 EXPECTED_FAILS: VALIDATION_CONFORMANCE_DOTNET VALIDATION_CONFORMANCE_JAVA VALIDATION_EXAMPLES_JAVA - name: Add & Commit diff --git a/ImplementationGuide/markdown/Einfuehrung.md b/ImplementationGuide/markdown/Einfuehrung.md index 0c80eaa9..90b4d1fb 100644 --- a/ImplementationGuide/markdown/Einfuehrung.md +++ b/ImplementationGuide/markdown/Einfuehrung.md @@ -1,9 +1,9 @@ gematik logo ---- -Version: 2.0.2 +Version: 2.0.3 -Datum: 31.01.2023 +Datum: 03.07.2024 Status: Aktiv diff --git a/ImplementationGuide/markdown/ReleaseNotes.md b/ImplementationGuide/markdown/ReleaseNotes.md index 9a97e1b8..8c35617f 100644 --- a/ImplementationGuide/markdown/ReleaseNotes.md +++ b/ImplementationGuide/markdown/ReleaseNotes.md @@ -7,9 +7,11 @@ Die erste Ziffer X bezeichnet ein Major-Release und regelt die Gültigkeit von R ---- Version: 2.0.3 -Datum: tbd +Datum: 03.07.2024 +- Entfernen von MS von MedicationStatement.partOf (Analog in Stufe 4.0.0-rc2) https://github.com/gematik/spec-ISiK-Medikation/pull/132 - Korrektur des Beispiels: ExampleISiKMedikationsListe.encounter, verweist jetzt korrekt auf einen Abteilungskontakt-Encounter https://github.com/gematik/spec-ISiK-Medikation/pull/128 + ---- Version: 2.0.2 diff --git a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationInformation.json b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationInformation.json index e75de9e4..5d931246 100644 --- a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationInformation.json +++ b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationInformation.json @@ -4,11 +4,11 @@ "url": "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/information", "status": "active", "experimental": false, - "version": "2.0.2", + "version": "2.0.3", "publisher": "gematik GmbH", - "date": "2023-01-31", + "date": "2024-07-03", "implementationGuide": [ - "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" + "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" ], "name": "ISiKCapabilityStatementMedikationInformation", "title": "ISiK CapabilityStatement Medikation Server - Medikationsinformation", diff --git a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerabreichung.json b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerabreichung.json index 5971c46b..7afa986e 100644 --- a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerabreichung.json +++ b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerabreichung.json @@ -4,11 +4,11 @@ "url": "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/verabreichung", "status": "active", "experimental": false, - "version": "2.0.2", + "version": "2.0.3", "publisher": "gematik GmbH", - "date": "2023-01-31", + "date": "2024-07-03", "implementationGuide": [ - "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" + "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" ], "name": "ISiKCapabilityStatementMedikationVerabreichung", "title": "ISiK CapabilityStatement Medikation Server - Medikationsverabreichung", diff --git a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerordnung.json b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerordnung.json index 539216dd..27049ea3 100644 --- a/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerordnung.json +++ b/Resources/fsh-generated/resources/CapabilityStatement-ISiKCapabilityStatementMedikationVerordnung.json @@ -4,11 +4,11 @@ "url": "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/verordnung", "status": "active", "experimental": false, - "version": "2.0.2", + "version": "2.0.3", "publisher": "gematik GmbH", - "date": "2023-01-31", + "date": "2024-07-03", "implementationGuide": [ - "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" + "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" ], "name": "ISiKCapabilityStatementMedikationVerordnung", "title": "ISiK CapabilityStatement Medikation Server - Medikationsverordnung", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikament.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikament.json index 65896a62..fa9540a6 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikament.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikament.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikament", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikament", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikament", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil ermöglicht die Abbildung von patientenunabhängigen Informationen zu Medikamenten in ISiK Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransaction.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransaction.json index 7b423a08..c275d0b7 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransaction.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransaction.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationTransaction", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationTransaction", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationTransaction", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil definiert die Transaktions-Bundles im Rahmen von ISiK-Medikations-Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransactionResponse.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransactionResponse.json index 44f67db8..468b0965 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransactionResponse.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationTransactionResponse.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationTransactionResponse", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationTransactionResponse", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationTransactionResponse", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil definiert die Server-Antwort auf Transaktions-Bundles im Rahmen von ISiK-Medikations-Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsInformation.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsInformation.json index cf04d6a6..51fc59fe 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsInformation.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsInformation.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationsInformation", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationsInformation", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationsInformation", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil ermöglicht die Abbildung von Informationen zur Medikation eines Patienten in ISiK Szenarien.", "fhirVersion": "4.0.1", @@ -23,12 +23,6 @@ "short": "eindeutige ID der Ressource auf dem Server", "mustSupport": true }, - { - "id": "MedicationStatement.partOf", - "path": "MedicationStatement.partOf", - "short": "Referenz auf andere Objekte, deren Bestandteil diese MedikationsInformation ist", - "mustSupport": true - }, { "id": "MedicationStatement.status", "path": "MedicationStatement.status", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsListe.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsListe.json index 273ef405..d65bdaa8 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsListe.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsListe.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationsListe", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationsListe", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationsListe", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil ermöglicht die Zusammenführung einzelner MedikationsInformationen eines Patienten in ISiK Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerabreichung.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerabreichung.json index 0bf54721..b786d968 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerabreichung.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerabreichung.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationsVerabreichung", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationsVerabreichung", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationsVerabreichung", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil ermöglicht die Abbildung der Verabreichung von Medikamenten für einen Patienten in ISiK Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerordnung.json b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerordnung.json index 487cfa38..fa8d329a 100644 --- a/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerordnung.json +++ b/Resources/fsh-generated/resources/StructureDefinition-ISiKMedikationsVerordnung.json @@ -2,11 +2,11 @@ "resourceType": "StructureDefinition", "id": "ISiKMedikationsVerordnung", "url": "https://gematik.de/fhir/isik/v2/Medikation/StructureDefinition/ISiKMedikationsVerordnung", - "version": "2.0.2", + "version": "2.0.3", "name": "ISiKMedikationsVerordnung", "status": "active", "experimental": false, - "date": "2023-01-31", + "date": "2024-07-03", "publisher": "gematik GmbH", "description": "Dieses Profil ermöglicht die Abbildung von Medikationsverordnungen eines Patienten in ISiK Szenarien.", "fhirVersion": "4.0.1", diff --git a/Resources/fsh-generated/resources/ValueSet-SctRouteOfAdministration.json b/Resources/fsh-generated/resources/ValueSet-SctRouteOfAdministration.json index 51ab4b3c..db096306 100644 --- a/Resources/fsh-generated/resources/ValueSet-SctRouteOfAdministration.json +++ b/Resources/fsh-generated/resources/ValueSet-SctRouteOfAdministration.json @@ -4,11 +4,11 @@ "name": "SctRouteOfAdministration", "id": "SctRouteOfAdministration", "description": "Enthaelt alle SNOMED CT Administrationsarten", - "version": "2.0.2", "url": "https://gematik.de/fhir/isik/v2/Medikation/ValueSet/SctRouteOfAdministration", "experimental": false, "publisher": "gematik GmbH", - "date": "2023-01-31", + "version": "2.0.3", + "date": "2024-07-03", "compose": { "include": [ { diff --git a/Resources/input/fsh/ISiKMedikationsInformation.fsh b/Resources/input/fsh/ISiKMedikationsInformation.fsh index e191c607..955739d7 100644 --- a/Resources/input/fsh/ISiKMedikationsInformation.fsh +++ b/Resources/input/fsh/ISiKMedikationsInformation.fsh @@ -5,8 +5,6 @@ Description: "Dieses Profil ermöglicht die Abbildung von Informationen zur Medi * insert Meta * id MS * ^short = "eindeutige ID der Ressource auf dem Server" -* partOf MS - * ^short = "Referenz auf andere Objekte, deren Bestandteil diese MedikationsInformation ist" * status MS * ^short = "Status der Medikationsinformation" * medication[x] MS diff --git a/Resources/input/fsh/ruleset.fsh b/Resources/input/fsh/ruleset.fsh index 984b85f8..0900b3b7 100644 --- a/Resources/input/fsh/ruleset.fsh +++ b/Resources/input/fsh/ruleset.fsh @@ -2,32 +2,32 @@ RuleSet: Meta * ^status = #active * ^experimental = false * ^publisher = "gematik GmbH" -* ^version = "2.0.2" -* ^date = "2023-01-31" +* ^version = "2.0.3" +* ^date = "2024-07-03" RuleSet: Meta-CapabilityStatementInformation * status = #active * experimental = false -* version = "2.0.2" +* version = "2.0.3" * publisher = "gematik GmbH" -* date = "2023-01-31" -* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" +* date = "2024-07-03" +* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" * url = "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/information" RuleSet: Meta-CapabilityStatementVerordnung * status = #active * experimental = false -* version = "2.0.2" +* version = "2.0.3" * publisher = "gematik GmbH" -* date = "2023-01-31" -* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" +* date = "2024-07-03" +* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" * url = "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/verordnung" RuleSet: Meta-CapabilityStatementVerabreichung * status = #active * experimental = false -* version = "2.0.2" +* version = "2.0.3" * publisher = "gematik GmbH" -* date = "2023-01-31" -* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.2" +* date = "2024-07-03" +* implementationGuide = "https://gematik.de/fhir/isik/v2/Medikation/ImplementationGuide|2.0.3" * url = "https://gematik.de/fhir/isik/v2/Medikation/CapabilityStatement/medikation-server/verabreichung" \ No newline at end of file diff --git a/Resources/sushi-config.yaml b/Resources/sushi-config.yaml index 4579472c..611c1dbb 100644 --- a/Resources/sushi-config.yaml +++ b/Resources/sushi-config.yaml @@ -3,8 +3,8 @@ fhirVersion: 4.0.1 FSHOnly: true applyExtensionMetadataToRoot: false status: active -version: 2.0.2 +version: 2.0.3 dependencies: de.medizininformatikinitiative.kerndatensatz.medikation: 1.0.10 hl7.fhir.r4.core: 4.0.1 - de.gematik.isik-basismodul: 2.0.4 + de.gematik.isik-basismodul: 2.0.x diff --git a/package.json b/package.json index b6f7ecde..9a387f57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "de.gematik.isik-medikation", - "version": "2.0.2", + "version": "2.0.3", "fhirVersions": [ "4.0.1" ], @@ -8,6 +8,6 @@ "hl7.fhir.r4.core": "4.0.1", "de.medizininformatikinitiative.kerndatensatz.medikation": "1.0.10", "hl7.fhir.uv.ips": "1.0.0", - "de.gematik.isik-basismodul": "2.0.4" + "de.gematik.isik-basismodul": "2.0.x" } } diff --git a/scripts/config.yaml b/scripts/config.yaml new file mode 100644 index 00000000..35ac3426 --- /dev/null +++ b/scripts/config.yaml @@ -0,0 +1,26 @@ +package.json: + - type: version + regex: '("version":\s*")([\d\.]+.*)(")' +sushi-config.yaml: + - type: version + regex: '(version:\s*)(\d+\.\d+\.\d+.*)()' +ruleset.fsh: + - type: version + regex: + - '(\*\s*version\s*=\s*")([\d\.]+.*)(")' + - '(\*\s*\^version\s*=\s*")([\d\.]+.*)(")' + - '(\*\s*implementationGuide\s*=\s*".*\|)([\d\.]+.*)(")' + - type: date + regex: + - '(\*\s*date\s*=\s*")(\d+\-\d+\-\d+)(")' + - '(\*\s*\^date\s*=\s*")(\d+\-\d+\-\d+)(")' + format: '%Y-%m-%d' +Einfuehrung.md: + - type: version + regex: '(Version: \s*)(\d+\.\d+\.\d+.*)()' + - type: date + regex: '(Datum:\s*)(\d+\.\d+\.\d+.*)()' + format: '%d.%m.%Y' +ImplementierungsleitfadenIsiK_Dokumentenaustausch.json: + - type: version + regex: '("version":\s*")(\d+\.\d+\.\d+.*)(",)' \ No newline at end of file diff --git a/scripts/release_publish.py b/scripts/release_publish.py new file mode 100644 index 00000000..cf93aa75 --- /dev/null +++ b/scripts/release_publish.py @@ -0,0 +1,165 @@ +import datetime +import re +import subprocess +import os +import argparse +from datetime import date +import yaml + + +class FileTypeCombinationToUpdate: + def __init__(self, filename, content_type, regex_list, format=None) -> None: + self.filename = filename + self.content_type = content_type + self.regex_list = regex_list + self.format = format + self.location = None + + def set_file_location(self, location): + self.location = location + + +def load_config_file(config_file_path): + with open(config_file_path, 'r') as config_file: + return yaml.safe_load(config_file) + +def get_new_release_version_from_branch_name() -> str: + git_branch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip().decode() + return git_branch + + +def modify_TC_branch_name_to_version(git_branch): + if git_branch.startswith('TC-'): + version = git_branch.lstrip('TC-') + elif git_branch.startswith('TC_'): + version = git_branch.lstrip('TC_') + return version + +def create_files_to_update_list(config): + files_to_update = [] + for filename, replacements in config.items(): + for replacement in replacements: + files_to_update.append( + FileTypeCombinationToUpdate( + filename, + replacement["type"], + replacement["regex"] if isinstance(replacement["regex"], list) else [replacement["regex"]], + replacement.get("format", None), + ) + ) + return files_to_update + + +def locate_files_in_current_project(files: list): + located_files = [] + for current_file in files: + file_location = find_file(current_file.filename, ".") + if file_location is not None: + current_file.set_file_location(file_location) + located_files.append(current_file) + else: + print(f"Warning: File '{current_file.filename}' not found.") + return located_files + + +def find_file(name, path="."): + for root, dirs, files in os.walk(path): + if name in files: + print(f"Info: Found '{name}' in {root}.") + return os.path.join(root, name) + return None + + +def replace_content_in_files(files: list, new_release_version: str, new_date: datetime): + if files is None: + print("Error: No files found!") + return + + for FileTypeCombination in files: + if FileTypeCombination.content_type == "version": + replace_version_in_file(FileTypeCombination, new_release_version) + elif FileTypeCombination.content_type == "date": + replace_date_in_file(FileTypeCombination, new_date) + + +def replace_version_in_file(file: FileTypeCombinationToUpdate, new_release_version: str): + with open(file.location, 'r') as input_file: + input_text = input_file.read() + + for regex in file.regex_list: + input_text = re.sub(regex, rf'\g<1>{new_release_version}\g<3>', input_text) + + print(f"Info: Replaced version with '{new_release_version}' in file '{file.location}'.") + + with open(file.location, 'w') as output_file: + output_file.write(input_text) + + +def replace_date_in_file(file: FileTypeCombinationToUpdate, new_date: datetime): + with open(file.location, 'r') as input_file: + input_text = input_file.read() + + for regex in file.regex_list: + input_text = re.sub(regex, rf'\g<1>{new_date.strftime(file.format)}\g<3>', input_text) + + print(f"Info: Replaced date with '{new_date.strftime(file.format)}' in file '{file.location}'.") + + with open(file.location, 'w') as output_file: + output_file.write(input_text) + +def output_commit_messages_since_last_release(): + latest_release_tag = get_latest_release_tag() + if latest_release_tag is None: + print("Warning: No release tag found.") + return + + cmd = f'git log --pretty=format:"%s" {latest_release_tag}..HEAD' + try: + output = subprocess.check_output(cmd, shell=True) + print(output.decode()) + except subprocess.CalledProcessError: + print("Warning: Failed to get commit messages.") + +def get_latest_release_tag(): + cmd = 'git describe --abbrev=0 --tags --match "v*.*.*" HEAD' + try: + output = subprocess.check_output(cmd, shell=True) + return output.decode().strip() + except subprocess.CalledProcessError: + return None + + +def main(): + parser = argparse.ArgumentParser(description='Update release version number and date') + parser.add_argument('-b', '--branch', action='store_true', help='get new version from branch name') + parser.add_argument('-v', '--version', type=str, help='specify new version number') + parser.add_argument('-d', '--date', type=str, help='specify custom date for release') + parser.add_argument('-c', '--config', type=str, default='config.yaml', help='specify config file') + parser.add_argument('-o', '--output', action='store_true', help='output commit messages since last release') + args = parser.parse_args() + + if args.version: + new_release_version = args.version + elif args.branch: + new_release_version = get_new_release_version_from_branch_name() + if new_release_version.startswith('TC'): + new_release_version = modify_TC_branch_name_to_version(new_release_version) + else: + parser.error('No new release version specified. Please use either -v or -b to specify the new release version.') + + if args.date: + custom_date = datetime.datetime.strptime(args.date, '%d.%m.%Y').date() + else: + custom_date = date.today() + + config_file_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), args.config) + config = load_config_file(config_file_path) + files_to_update = create_files_to_update_list(config) + located_files = locate_files_in_current_project(files_to_update) + replace_content_in_files(located_files, new_release_version, custom_date) + + if args.output: + output_commit_messages_since_last_release() + +if __name__ == "__main__": + main() \ No newline at end of file