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 @@ -201,6 +201,7 @@ Release Please automates releases for the following flavors of repositories:
| `sfdx` | A repository with a [sfdx-project.json](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) and a CHANGELOG.md |
| `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) |
| `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) |
| `deno` | A repository with a deno.json, deno.jsonc, or jsr.json and a CHANGELOG.md |

## Setting up Release Please

Expand Down
20 changes: 10 additions & 10 deletions __snapshots__/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ Options:
[string]
--release-type what type of repo is a release being created
for?
[choices: "bazel", "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi",
"helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi",
"java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php",
"php-yoshi", "python", "r", "ruby", "ruby-yoshi", "rust", "salesforce",
"sfdx", "simple", "terraform-module"]
[choices: "bazel", "dart", "deno", "dotnet-yoshi", "elixir", "expo", "go",
"go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts",
"java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node",
"ocaml", "php", "php-yoshi", "python", "r", "ruby", "ruby-yoshi", "rust",
"salesforce", "sfdx", "simple", "terraform-module"]
--config-file where can the config file be found in the
project? [default: "release-please-config.json"]
--manifest-file where can the manifest file be found in the
Expand Down Expand Up @@ -250,11 +250,11 @@ Options:
[string]
--release-type what type of repo is a release being created
for?
[choices: "bazel", "dart", "dotnet-yoshi", "elixir", "expo", "go", "go-yoshi",
"helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi",
"java-yoshi-mono-repo", "krm-blueprint", "maven", "node", "ocaml", "php",
"php-yoshi", "python", "r", "ruby", "ruby-yoshi", "rust", "salesforce",
"sfdx", "simple", "terraform-module"]
[choices: "bazel", "dart", "deno", "dotnet-yoshi", "elixir", "expo", "go",
"go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts",
"java-yoshi", "java-yoshi-mono-repo", "krm-blueprint", "maven", "node",
"ocaml", "php", "php-yoshi", "python", "r", "ruby", "ruby-yoshi", "rust",
"salesforce", "sfdx", "simple", "terraform-module"]
--config-file where can the config file be found in the
project?
[default: "release-please-config.json"]
Expand Down
56 changes: 56 additions & 0 deletions __snapshots__/deno-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
exports['Deno updateContent updates the package version with deno.json 1'] = `
{
"name": "@deno/esbuild-plugin",
"version": "2.0.0",
"license": "MIT",
"imports": {
"@deno/loader": "jsr:@deno/loader@^0.3.3",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/path": "jsr:@std/path@^1.1.1",
"esbuild": "npm:esbuild@^0.25.5",
"fflate": "npm:fflate@^0.8.2",
"mime-db": "npm:mime-db@^1.54.0",
"preact": "npm:preact@^10.26.8",
"mapped": "./tests/fixtures/simple.ts"
}
}

`

exports['Deno updateContent updates the package version with deno.jsonc 1'] = `
{
"name": "@deno/esbuild-plugin",
"version": "2.0.0",
"license": "MIT",
"imports": {
"@deno/loader": "jsr:@deno/loader@^0.3.3",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/path": "jsr:@std/path@^1.1.1",
"esbuild": "npm:esbuild@^0.25.5",
"fflate": "npm:fflate@^0.8.2",
"mime-db": "npm:mime-db@^1.54.0",
"preact": "npm:preact@^10.26.8",
"mapped": "./tests/fixtures/simple.ts"
}
}

`

exports['Deno updateContent updates the package version with jsr.json 1'] = `
{
"name": "@deno/esbuild-plugin",
"version": "2.0.0",
"license": "MIT",
"imports": {
"@deno/loader": "jsr:@deno/loader@^0.3.3",
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/path": "jsr:@std/path@^1.1.1",
"esbuild": "npm:esbuild@^0.25.5",
"fflate": "npm:fflate@^0.8.2",
"mime-db": "npm:mime-db@^1.54.0",
"preact": "npm:preact@^10.26.8",
"mapped": "./tests/fixtures/simple.ts"
}
}

`
37 changes: 37 additions & 0 deletions __snapshots__/deno.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
exports['Deno buildReleasePullRequest updates changelog.json if present 1'] = `
{
"entries": [
{
"changes": [
{
"type": "fix",
"sha": "845db1381b3d5d20151cad2588f85feb",
"message": "update dependency com.google.cloud:google-cloud-storage to v1.120.0",
"issues": [],
"scope": "deps"
},
{
"type": "chore",
"sha": "b3f8966b023b8f21ce127142aa91841c",
"message": "update a very important dep",
"issues": [],
"breakingChangeNote": "update a very important dep"
},
{
"type": "fix",
"sha": "08ca01180a91c0a1ba8992b491db9212",
"message": "update dependency com.google.cloud:google-cloud-spanner to v1.50.0",
"issues": [],
"scope": "deps"
}
],
"version": "1.0.0",
"language": "TYPESCRIPT",
"artifactName": "deno-test-repo",
"id": "abc-123-efd-qwerty",
"createTime": "2023-01-05T16:42:33.446Z"
}
],
"updateTime": "2023-01-05T16:42:33.446Z"
}
`
1 change: 1 addition & 0 deletions docs/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Release Please automates releases for the following flavors of repositories:
| `sfdx` | A repository with a [sfdx-project.json](https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_ws_config.htm) and a CHANGELOG.md |
| `simple` | [A repository with a version.txt and a CHANGELOG.md](https://github.com/googleapis/gapic-generator) |
| `terraform-module` | [A terraform module, with a version in the README.md, and a CHANGELOG.md](https://github.com/terraform-google-modules/terraform-google-project-factory) |
| `deno` | A repository with a deno.json, deno.jsonc, or jsr.json and a CHANGELOG.md |

### Adding additional strategy types

Expand Down
2 changes: 2 additions & 0 deletions src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {ReleaserConfig} from './manifest';
import {BaseStrategyOptions} from './strategies/base';
import {Bazel} from './strategies/bazel';
import {Dart} from './strategies/dart';
import {Deno} from './strategies/deno';
import {DotnetYoshi} from './strategies/dotnet-yoshi';
import {Elixir} from './strategies/elixir';
import {Expo} from './strategies/expo';
Expand Down Expand Up @@ -111,6 +112,7 @@ const releasers: Record<string, ReleaseBuilder> = {
elixir: options => new Elixir(options),
dart: options => new Dart(options),
bazel: options => new Bazel(options),
deno: options => new Deno(options),
};

export async function buildStrategy(
Expand Down
112 changes: 112 additions & 0 deletions src/strategies/deno.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// 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.
// Copyright 2025 Google LLC
// Licensed under the Apache License, Version 2.0

import {GitHubFileContents} from '@google-automations/git-file-utils';
import {FileNotFoundError, MissingRequiredFileError} from '../errors';
import {Update} from '../update';
import {Changelog} from '../updaters/changelog';
import {ChangelogJson} from '../updaters/changelog-json';
import {filterCommits} from '../util/filter-commits';
import {BaseStrategy, BuildUpdatesOptions} from './base';
import {DenoJson} from '../updaters/deno/deno-json';

const CONFIG_FILES = ['deno.json', 'deno.jsonc', 'jsr.json'];

export class Deno extends BaseStrategy {
private denoConfigContents?: GitHubFileContents;
private denoConfigPath?: string;

protected async buildUpdates(
options: BuildUpdatesOptions
): Promise<Update[]> {
const updates: Update[] = [];
const version = options.newVersion;
const packageName = (await this.getDefaultPackageName()) ?? '';

// Update config file
if (this.denoConfigPath && this.denoConfigContents) {
updates.push({
path: this.addPath(this.denoConfigPath),
createIfMissing: false,
cachedFileContents: this.denoConfigContents,
updater: new DenoJson({version}),
});
}

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

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

return updates;
}

async getDefaultPackageName(): Promise<string | undefined> {
const configContents = await this.getDenoConfigContents();
const config = JSON.parse(configContents.parsedContent);
return config.name;
}

protected async getDenoConfigContents(): Promise<GitHubFileContents> {
if (!this.denoConfigContents) {
for (const file of CONFIG_FILES) {
try {
this.denoConfigContents = await this.github.getFileContentsOnBranch(
this.addPath(file),
this.targetBranch
);
this.denoConfigPath = file;
break;
} catch (e) {
if (!(e instanceof FileNotFoundError)) {
throw e;
}
}
}

if (!this.denoConfigContents || !this.denoConfigPath) {
throw new MissingRequiredFileError(
CONFIG_FILES.join(', '),
'deno',
`${this.repository.owner}/${this.repository.repo}`
);
}
}
return this.denoConfigContents;
}
}
47 changes: 47 additions & 0 deletions src/updaters/deno/deno-json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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 {jsonStringify} from '../../util/json-stringify';
import {logger as defaultLogger, Logger} from '../../util/logger';
import {DefaultUpdater, UpdateOptions} from '../default';

export type DenoJsonDescriptor = {
name?: string;
version: string;
};

export type DenoJsonOptions = UpdateOptions;

/**
* This updates a Deno deno.json file's main version.
*/
export class DenoJson extends DefaultUpdater {
constructor(options: DenoJsonOptions) {
super(options);
}

/**
* Given initial file contents, return updated contents.
* @param {string} content The initial content
* @param logger
* @returns {string} The updated content
*/
updateContent(content: string, logger: Logger = defaultLogger): string {
const parsed = JSON.parse(content) as DenoJsonDescriptor;
logger.info(`updating from ${parsed.version} to ${this.version}`);
parsed.version = this.version.toString();

return jsonStringify(parsed, content);
}
}
4 changes: 4 additions & 0 deletions test/fixtures/strategies/deno/changelog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"repository": "google-cloud-deno",
"entries": []
}
Loading
Loading