mirror of
https://github.com/denoland/deno.git
synced 2025-03-10 14:17:49 -04:00
ci: bump CI cache version on CLI version bump (#19318)
Automatically bump the CI cache version
This commit is contained in:
parent
f63b13fc96
commit
e1391e2054
2 changed files with 31 additions and 3 deletions
10
.github/workflows/ci.generate.ts
vendored
10
.github/workflows/ci.generate.ts
vendored
|
@ -2,6 +2,11 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import * as yaml from "https://deno.land/std@0.173.0/encoding/yaml.ts";
|
import * as yaml from "https://deno.land/std@0.173.0/encoding/yaml.ts";
|
||||||
|
|
||||||
|
// Bump this number when you want to purge the cache.
|
||||||
|
// Note: the tools/release/01_bump_crate_versions.ts script will update this version
|
||||||
|
// automatically via regex, so ensure that this line maintains this format.
|
||||||
|
const cacheVersion = 32;
|
||||||
|
|
||||||
const Runners = (() => {
|
const Runners = (() => {
|
||||||
const ubuntuRunner = "ubuntu-22.04";
|
const ubuntuRunner = "ubuntu-22.04";
|
||||||
const ubuntuXlRunner = "ubuntu-22.04-xl";
|
const ubuntuXlRunner = "ubuntu-22.04-xl";
|
||||||
|
@ -15,9 +20,8 @@ const Runners = (() => {
|
||||||
windows: "windows-2022",
|
windows: "windows-2022",
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
// bump the number at the start when you want to purge the cache
|
|
||||||
const prCacheKeyPrefix =
|
const prCacheKeyPrefix =
|
||||||
"32-cargo-target-${{ matrix.os }}-${{ matrix.profile }}-${{ matrix.job }}-";
|
`${cacheVersion}-cargo-target-\${{ matrix.os }}-\${{ matrix.profile }}-\${{ matrix.job }}-`;
|
||||||
|
|
||||||
const installPkgsCommand =
|
const installPkgsCommand =
|
||||||
"sudo apt-get install --no-install-recommends debootstrap clang-15 lld-15";
|
"sudo apt-get install --no-install-recommends debootstrap clang-15 lld-15";
|
||||||
|
@ -480,7 +484,7 @@ const ci = {
|
||||||
"~/.cargo/git/db",
|
"~/.cargo/git/db",
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
key:
|
key:
|
||||||
"32-cargo-home-${{ matrix.os }}-${{ hashFiles('Cargo.lock') }}",
|
`${cacheVersion}-cargo-home-\${{ matrix.os }}-\${{ hashFiles('Cargo.lock') }}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@ const repo = workspace.repo;
|
||||||
const cliCrate = workspace.getCliCrate();
|
const cliCrate = workspace.getCliCrate();
|
||||||
const originalCliVersion = cliCrate.version;
|
const originalCliVersion = cliCrate.version;
|
||||||
|
|
||||||
|
await bumpCiCacheVersion();
|
||||||
|
|
||||||
// increment the cli version
|
// increment the cli version
|
||||||
if (Deno.args.some((a) => a === "--patch")) {
|
if (Deno.args.some((a) => a === "--patch")) {
|
||||||
await cliCrate.increment("patch");
|
await cliCrate.increment("patch");
|
||||||
|
@ -110,3 +112,25 @@ async function updateStdVersion() {
|
||||||
text.replace(versionRe, `std@${newStdVersion}`),
|
text.replace(versionRe, `std@${newStdVersion}`),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function bumpCiCacheVersion() {
|
||||||
|
const generateScript = workspace.repo.folderPath.join(
|
||||||
|
".github/workflows/ci.generate.ts",
|
||||||
|
);
|
||||||
|
const fileText = generateScript.readTextSync();
|
||||||
|
const cacheVersionRegex = /const cacheVersion = ([0-9]+);/;
|
||||||
|
const version = fileText.match(cacheVersionRegex)?.[1];
|
||||||
|
if (version == null) {
|
||||||
|
throw new Error("Could not find cache version in text.");
|
||||||
|
}
|
||||||
|
const toVersion = parseInt(version, 10) + 1;
|
||||||
|
$.logStep(`Bumping cache version from ${version} to ${toVersion}...`);
|
||||||
|
const newText = fileText.replace(
|
||||||
|
cacheVersionRegex,
|
||||||
|
`const cacheVersion = ${toVersion};`,
|
||||||
|
);
|
||||||
|
generateScript.writeTextSync(newText);
|
||||||
|
|
||||||
|
// run the script
|
||||||
|
await $`${generateScript}`;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue