From b96be9beb58beea9373459e6ce80d3db191fa661 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Sat, 16 Nov 2024 11:49:27 +0100 Subject: [PATCH] feat(python): read version-file from manifest --- src/strategies/base.ts | 2 ++ src/strategies/python.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/strategies/base.ts b/src/strategies/base.ts index 00495e426..6a207617b 100644 --- a/src/strategies/base.ts +++ b/src/strategies/base.ts @@ -113,6 +113,7 @@ export abstract class BaseStrategy implements Strategy { readonly componentNoSpace?: boolean; readonly extraFiles: ExtraFile[]; readonly extraLabels: string[]; + readonly versionFile?: string; readonly changelogNotes: ChangelogNotes; @@ -148,6 +149,7 @@ export abstract class BaseStrategy implements Strategy { this.extraFiles = options.extraFiles || []; this.initialVersion = options.initialVersion; this.extraLabels = options.extraLabels || []; + this.versionFile = options.versionFile; } /** diff --git a/src/strategies/python.ts b/src/strategies/python.ts index 5287b9451..9eb041490 100644 --- a/src/strategies/python.ts +++ b/src/strategies/python.ts @@ -105,7 +105,15 @@ export class Python extends BaseStrategy { if (!projectName) { this.logger.warn('No project/component found.'); } else { - [projectName, projectName.replace(/-/g, '_')] + if (this.versionFile) { + const versionFilePath = this.addPath(this.versionFile); + updates.push({ + path: versionFilePath, + createIfMissing: true, + updater: new PythonFileWithVersion({version}), + }); + } else { + [projectName, projectName.replace(/-/g, '_')] .flatMap(packageName => [ `${packageName}/__init__.py`, `src/${packageName}/__init__.py`, @@ -117,6 +125,7 @@ export class Python extends BaseStrategy { updater: new PythonFileWithVersion({version}), }) ); + } } // There should be only one version.py, but foreach in case that is incorrect