Skip to content

Commit

Permalink
feat(python): read version-file from manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Nov 16, 2024
1 parent 3e80797 commit b96be9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

/**
Expand Down
11 changes: 10 additions & 1 deletion src/strategies/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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
Expand Down

0 comments on commit b96be9b

Please sign in to comment.