-
Notifications
You must be signed in to change notification settings - Fork 953
/
Copy pathrelease.tags.push.mjs
41 lines (34 loc) · 1.06 KB
/
release.tags.push.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env zx
// @ts-check
import "zx/globals";
import { getLocalTags, getRemoteTags } from "./tools/git.mjs";
const localTags = await getLocalTags();
const remoteTags = await getRemoteTags();
const isCi = process.env.CI === "true";
// find all the tags that are local but not remote
const tagsToPush = localTags.filter((tag) => !remoteTags.includes(tag));
if (tagsToPush.length === 0) {
console.log(`No tags to push`);
process.exit(0);
}
console.log(
`${tagsToPush.length} tag(s) to push: ${os.EOL}${tagsToPush.join(", ")}${
os.EOL
}`
);
console.log("Pushing tags one at a time");
console.log(
"This is because github does not trigger webhooks when pushing more than 3 tags at once"
);
console.log(
"'https://support.circleci.com/hc/en-us/articles/360052198651-When-I-Push-4-or-More-Tags-in-a-Single-Push-No-CircleCI-Workflows-Are-Triggered'"
);
console.log(os.EOL);
for (const tag of tagsToPush) {
console.log(`Pushing tag: '${tag}'`);
if (isCi) {
await $`git push origin ${tag}`.quiet();
} else {
console.log("Not in CI, skipping push");
}
}