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 5ab0703
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
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
29 changes: 17 additions & 12 deletions src/strategies/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,23 @@ export class Python extends BaseStrategy {
if (!projectName) {
this.logger.warn('No project/component found.');
} else {
[projectName, projectName.replace(/-/g, '_')]
.flatMap(packageName => [
`${packageName}/__init__.py`,
`src/${packageName}/__init__.py`,
])
.forEach(packagePath =>
updates.push({
path: this.addPath(packagePath),
createIfMissing: false,
updater: new PythonFileWithVersion({version}),
})
);
const versionFiles = this.versionFile
? [this.versionFile]
: [projectName, projectName.replace(/-/g, '_')]
.flatMap(packageName => [
`${packageName}/__init__.py`,
`src/${packageName}/__init__.py`,
]);
if (versionFiles.length > 0) {
const packagePath = versionFiles[0];
updates.push({
path: this.addPath(packagePath),
createIfMissing: false,
updater: new PythonFileWithVersion({version}),
});
} else {
this.logger.warn('No version file found.');
}
}

// There should be only one version.py, but foreach in case that is incorrect
Expand Down

0 comments on commit 5ab0703

Please sign in to comment.