Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Release Please automates releases for the following flavors of repositories:
| `go` | A repository with a CHANGELOG.md |
| `helm` | A repository with a Chart.yaml and a CHANGELOG.md |
| `java` | [A strategy that generates SNAPSHOT version after each release](docs/java.md) |
| `julia` | [A Julia package repository with a Project.toml or JuliaProject.toml, and a CHANGELOG.md.](https://github.com/JuliaDocs/Documenter.jl) |
| `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
| `maven` | [Strategy for Maven projects, generates SNAPSHOT version after each release and updates `pom.xml` automatically](docs/java.md) |
| `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
Expand Down
7 changes: 7 additions & 0 deletions __snapshots__/julia-project-toml.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports['JuliaProject.toml updateContent updates version in JuliaProject.toml 1'] = `
name = "ReleasePleaseJuliaStategy"
uuid = "7d294f08-cb76-428f-b375-a2356da1b9f0"
authors = ["Google LLC <bot@users.noreply.github.com>>"]
version = "0.6.0"

`
1 change: 1 addition & 0 deletions docs/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Release Please automates releases for the following flavors of repositories:
| `go` | A repository with a CHANGELOG.md |
| `helm` | A repository with a Chart.yaml and a CHANGELOG.md |
| `java` | [A strategy that generates SNAPSHOT version after each release](java.md) |
| `julia` | [A Julia package repository with a Project.toml or JuliaProject.toml, and a CHANGELOG.md.](https://github.com/JuliaDocs/Documenter.jl) |
| `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
| `maven` | [Strategy for Maven projects, generates SNAPSHOT version after each release and updates `pom.xml` automatically](java.md) |
| `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "./build/src/index.js",
"bin": "./build/src/bin/release-please.js",
"scripts": {
"test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --node-option no-experimental-fetch --recursive --timeout=5000 build/test",
"test": "cross-env ENVIRONMENT=test LC_ALL=en c8 mocha --recursive --timeout=5000 build/test",
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about this change, but I needed it to run tests locally.

"docs": "echo add docs tests",
"test:snap": "cross-env SNAPSHOT_UPDATE=1 LC_ALL=en npm test",
"clean": "gts clean",
Expand Down
2 changes: 2 additions & 0 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {Helm} from './strategies/helm';
import {Java} from './strategies/java';
import {JavaYoshi} from './strategies/java-yoshi';
import {JavaYoshiMonoRepo} from './strategies/java-yoshi-mono-repo';
import {Julia} from './strategies/julia';
import {KRMBlueprint} from './strategies/krm-blueprint';
import {Maven} from './strategies/maven';
import {Node} from './strategies/node';
Expand Down Expand Up @@ -92,6 +93,7 @@ const releasers: Record<string, ReleaseBuilder> = {
...options,
versioningStrategy: new ServicePackVersioningStrategy(),
}),
julia: options => new Julia(options),
'krm-blueprint': options => new KRMBlueprint(options),
node: options => new Node(options),
expo: options => new Expo(options),
Expand Down
149 changes: 149 additions & 0 deletions src/strategies/julia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import {BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions} from './base';
import {Update} from '../update';
import {Changelog} from '../updaters/changelog';
import {ChangelogJson} from '../updaters/changelog-json';
import {Version} from '../version';
import {
JuliaProject,
parseJuliaProject,
JuliaProjectToml,
} from '../updaters/julia/project-toml';
import {filterCommits} from '../util/filter-commits';

const CHANGELOG_SECTIONS = [
{type: 'feat', section: 'Features'},
{type: 'fix', section: 'Bug Fixes'},
{type: 'perf', section: 'Performance Improvements'},
{type: 'deps', section: 'Dependencies'},
{type: 'revert', section: 'Reverts'},
{type: 'docs', section: 'Documentation'},
{type: 'style', section: 'Styles', hidden: true},
{type: 'chore', section: 'Miscellaneous Chores', hidden: true},
{type: 'refactor', section: 'Code Refactoring', hidden: true},
{type: 'test', section: 'Tests', hidden: true},
{type: 'build', section: 'Build System', hidden: true},
{type: 'ci', section: 'Continuous Integration', hidden: true},
];

export class Julia extends BaseStrategy {
constructor(options: BaseStrategyOptions) {
options.changelogSections = options.changelogSections ?? CHANGELOG_SECTIONS;
super(options);
}

protected async buildUpdates(
options: BuildUpdatesOptions
): Promise<Update[]> {
const updates: Update[] = [];
const version = options.newVersion;

!this.skipChangelog &&
updates.push({
path: this.addPath(this.changelogPath),
createIfMissing: true,
updater: new Changelog({
version,
changelogEntry: options.changelogEntry,
}),
});

let parsedJuliaProject = await this.getJuliaProject(
this.addPath('Project.toml')
);

let juliaProject = parsedJuliaProject;
let projectName = this.component;
if (juliaProject) {
updates.push({
path: this.addPath('Project.toml'),
createIfMissing: false,
updater: new JuliaProjectToml({
version,
}),
});
projectName = juliaProject.name;
} else {
this.logger.warn(
parsedJuliaProject
? 'invalid Project.toml'
: `file ${this.addPath('Project.toml')} did not exist`
);
}

parsedJuliaProject = await this.getJuliaProject(
this.addPath('JuliaProject.toml')
);

juliaProject = parsedJuliaProject;

projectName = this.component;
if (juliaProject) {
updates.push({
path: this.addPath('JuliaProject.toml'),
createIfMissing: false,
updater: new JuliaProjectToml({
version,
}),
});
projectName = juliaProject.name;
} else {
this.logger.warn(
parsedJuliaProject
? 'invalid JuliaProject.toml'
: `file ${this.addPath('JuliaProject.toml')} did not exist`
);
}

if (!projectName) {
this.logger.warn('No project/component found.');
}

// If a machine readable changelog.json exists update it:
const artifactName = projectName;
if (options.commits && artifactName && !this.skipChangelog) {
const commits = filterCommits(options.commits, this.changelogSections);
updates.push({
path: 'changelog.json',
createIfMissing: false,
updater: new ChangelogJson({
artifactName,
version,
commits,
language: 'JULIA',
}),
});
}

return updates;
}

private async getJuliaProject(path: string): Promise<JuliaProject | null> {
try {
const content = await this.github.getFileContentsOnBranch(
path,
this.targetBranch
);
return parseJuliaProject(content.parsedContent);
} catch (e) {
return null;
}
}

protected initialReleaseVersion(): Version {
return Version.parse('0.1.0');
}
}
52 changes: 52 additions & 0 deletions src/updaters/julia/project-toml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import * as TOML from '@iarna/toml';
import {logger as defaultLogger, Logger} from '../../util/logger';
import {replaceTomlValue} from '../../util/toml-edit';
import {DefaultUpdater} from '../default';

/**
* A subset of the contents of a Julia `Project.toml` or `JuliaProject.toml`
*/
export interface JuliaProject {
name?: string;
version?: string;
}

export function parseJuliaProject(content: string): JuliaProject {
return TOML.parse(content) as JuliaProject;
}

/**
* Updates a Julia Project.toml or JuliaProject.toml file
*/
export class JuliaProjectToml extends DefaultUpdater {
/**
* Given initial file contents, return updated contents.
* @param {string} content The initial content
* @returns {string} The updated content
*/
updateContent(content: string, logger: Logger = defaultLogger): string {
const parsed = parseJuliaProject(content);

if (!parsed.version) {
const msg = 'invalid file';
logger.error(msg);
throw new Error(msg);
}

return replaceTomlValue(content, ['version'], this.version.toString());
}
}
4 changes: 4 additions & 0 deletions test/fixtures/strategies/julia/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name = "ReleasePleaseJuliaStategy"
uuid = "7d294f08-cb76-428f-b375-a2356da1b9f0"
authors = ["Google LLC <bot@users.noreply.github.com>>"]
version = "0.5.0"
Loading
Loading