mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -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()) {
|
||||
await crate.increment("minor");
|
||||
}
|
||||
|
||||
await workspace.updateLockFile();
|
||||
|
|
|
@ -13,6 +13,7 @@ const originalVersion = cliCrate.version;
|
|||
|
||||
// increment the version
|
||||
await cliCrate.increment(getVersionIncrement());
|
||||
await workspace.updateLockFile();
|
||||
|
||||
// output the Releases.md markdown text
|
||||
console.log(
|
||||
|
|
|
@ -33,10 +33,34 @@ export async function getMetadata(directory: string) {
|
|||
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({
|
||||
cwd: directory,
|
||||
cmd: ["cargo", "publish"],
|
||||
cwd: params.directory,
|
||||
cmd: ["cargo", ...params.args],
|
||||
stderr: "inherit",
|
||||
stdout: "inherit",
|
||||
});
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
|
||||
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 {
|
||||
CargoMetadata,
|
||||
CargoPackageMetadata,
|
||||
getMetadata,
|
||||
publishCrate,
|
||||
} from "./cargo.ts";
|
||||
import * as cargo from "./cargo.ts";
|
||||
import { getCratesIoMetadata } from "./crates_io.ts";
|
||||
import { withRetries } from "./helpers.ts";
|
||||
|
||||
|
@ -21,10 +16,12 @@ export class 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 = [];
|
||||
for (const memberId of metadata.workspace_members) {
|
||||
const pkg = metadata.packages.find((pkg) => pkg.id === memberId);
|
||||
|
@ -82,14 +79,22 @@ export class DenoWorkspace {
|
|||
}
|
||||
return crate;
|
||||
}
|
||||
|
||||
build() {
|
||||
return cargo.build(DenoWorkspace.rootDirPath);
|
||||
}
|
||||
|
||||
updateLockFile() {
|
||||
return cargo.check(DenoWorkspace.rootDirPath);
|
||||
}
|
||||
}
|
||||
|
||||
export class DenoWorkspaceCrate {
|
||||
#workspace: DenoWorkspace;
|
||||
#pkg: CargoPackageMetadata;
|
||||
#pkg: cargo.CargoPackageMetadata;
|
||||
#isUpdatingManifest = false;
|
||||
|
||||
constructor(workspace: DenoWorkspace, pkg: CargoPackageMetadata) {
|
||||
constructor(workspace: DenoWorkspace, pkg: cargo.CargoPackageMetadata) {
|
||||
this.#workspace = workspace;
|
||||
this.#pkg = pkg;
|
||||
}
|
||||
|
@ -141,7 +146,7 @@ export class DenoWorkspaceCrate {
|
|||
// times before failing hard.
|
||||
return await withRetries({
|
||||
action: async () => {
|
||||
await publishCrate(this.directoryPath);
|
||||
await cargo.publishCrate(this.directoryPath);
|
||||
return true;
|
||||
},
|
||||
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") {
|
||||
const newVersion = semver.parse(this.version)!.inc(part).toString();
|
||||
return this.setVersion(newVersion);
|
||||
|
|
Loading…
Reference in a new issue