mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
chore: release scripts should update Cargo.lock file when bumping versions (#11879)
This commit is contained in:
parent
0aa6b1e79f
commit
ca75752e5a
4 changed files with 54 additions and 14 deletions
|
@ -7,3 +7,5 @@ const workspace = await DenoWorkspace.load();
|
||||||
for (const crate of workspace.getDependencyCrates()) {
|
for (const crate of workspace.getDependencyCrates()) {
|
||||||
await crate.increment("minor");
|
await crate.increment("minor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await workspace.updateLockFile();
|
||||||
|
|
|
@ -13,6 +13,7 @@ const originalVersion = cliCrate.version;
|
||||||
|
|
||||||
// increment the version
|
// increment the version
|
||||||
await cliCrate.increment(getVersionIncrement());
|
await cliCrate.increment(getVersionIncrement());
|
||||||
|
await workspace.updateLockFile();
|
||||||
|
|
||||||
// output the Releases.md markdown text
|
// output the Releases.md markdown text
|
||||||
console.log(
|
console.log(
|
||||||
|
|
|
@ -33,10 +33,34 @@ export async function getMetadata(directory: string) {
|
||||||
return JSON.parse(result!) as CargoMetadata;
|
return JSON.parse(result!) as CargoMetadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function publishCrate(directory: string) {
|
export function publishCrate(directory: string) {
|
||||||
|
return runCargoSubCommand({
|
||||||
|
directory,
|
||||||
|
args: ["publish"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function build(directory: string) {
|
||||||
|
return runCargoSubCommand({
|
||||||
|
directory,
|
||||||
|
args: ["build", "-vv"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function check(directory: string) {
|
||||||
|
return runCargoSubCommand({
|
||||||
|
directory,
|
||||||
|
args: ["check"],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runCargoSubCommand(params: {
|
||||||
|
args: string[];
|
||||||
|
directory: string;
|
||||||
|
}) {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cwd: directory,
|
cwd: params.directory,
|
||||||
cmd: ["cargo", "publish"],
|
cmd: ["cargo", ...params.args],
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
stdout: "inherit",
|
stdout: "inherit",
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,7 @@
|
||||||
|
|
||||||
import * as path from "https://deno.land/std@0.105.0/path/mod.ts";
|
import * as path from "https://deno.land/std@0.105.0/path/mod.ts";
|
||||||
import * as semver from "https://deno.land/x/semver@v1.4.0/mod.ts";
|
import * as semver from "https://deno.land/x/semver@v1.4.0/mod.ts";
|
||||||
import {
|
import * as cargo from "./cargo.ts";
|
||||||
CargoMetadata,
|
|
||||||
CargoPackageMetadata,
|
|
||||||
getMetadata,
|
|
||||||
publishCrate,
|
|
||||||
} from "./cargo.ts";
|
|
||||||
import { getCratesIoMetadata } from "./crates_io.ts";
|
import { getCratesIoMetadata } from "./crates_io.ts";
|
||||||
import { withRetries } from "./helpers.ts";
|
import { withRetries } from "./helpers.ts";
|
||||||
|
|
||||||
|
@ -21,10 +16,12 @@ export class DenoWorkspace {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async load(): Promise<DenoWorkspace> {
|
static async load(): Promise<DenoWorkspace> {
|
||||||
return new DenoWorkspace(await getMetadata(DenoWorkspace.rootDirPath));
|
return new DenoWorkspace(
|
||||||
|
await cargo.getMetadata(DenoWorkspace.rootDirPath),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private constructor(metadata: CargoMetadata) {
|
private constructor(metadata: cargo.CargoMetadata) {
|
||||||
const crates = [];
|
const crates = [];
|
||||||
for (const memberId of metadata.workspace_members) {
|
for (const memberId of metadata.workspace_members) {
|
||||||
const pkg = metadata.packages.find((pkg) => pkg.id === memberId);
|
const pkg = metadata.packages.find((pkg) => pkg.id === memberId);
|
||||||
|
@ -82,14 +79,22 @@ export class DenoWorkspace {
|
||||||
}
|
}
|
||||||
return crate;
|
return crate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
return cargo.build(DenoWorkspace.rootDirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLockFile() {
|
||||||
|
return cargo.check(DenoWorkspace.rootDirPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DenoWorkspaceCrate {
|
export class DenoWorkspaceCrate {
|
||||||
#workspace: DenoWorkspace;
|
#workspace: DenoWorkspace;
|
||||||
#pkg: CargoPackageMetadata;
|
#pkg: cargo.CargoPackageMetadata;
|
||||||
#isUpdatingManifest = false;
|
#isUpdatingManifest = false;
|
||||||
|
|
||||||
constructor(workspace: DenoWorkspace, pkg: CargoPackageMetadata) {
|
constructor(workspace: DenoWorkspace, pkg: cargo.CargoPackageMetadata) {
|
||||||
this.#workspace = workspace;
|
this.#workspace = workspace;
|
||||||
this.#pkg = pkg;
|
this.#pkg = pkg;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +146,7 @@ export class DenoWorkspaceCrate {
|
||||||
// times before failing hard.
|
// times before failing hard.
|
||||||
return await withRetries({
|
return await withRetries({
|
||||||
action: async () => {
|
action: async () => {
|
||||||
await publishCrate(this.directoryPath);
|
await cargo.publishCrate(this.directoryPath);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
retryCount: 3,
|
retryCount: 3,
|
||||||
|
@ -149,6 +154,14 @@ export class DenoWorkspaceCrate {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
return cargo.build(this.directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLockFile() {
|
||||||
|
return cargo.check(this.directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
increment(part: "major" | "minor" | "patch") {
|
increment(part: "major" | "minor" | "patch") {
|
||||||
const newVersion = semver.parse(this.version)!.inc(part).toString();
|
const newVersion = semver.parse(this.version)!.inc(part).toString();
|
||||||
return this.setVersion(newVersion);
|
return this.setVersion(newVersion);
|
||||||
|
|
Loading…
Reference in a new issue