Skip to content

Commit df41a9b

Browse files
committed
Added a script to recover tags if needed
1 parent 056a92b commit df41a9b

File tree

5 files changed

+41
-6
lines changed

5 files changed

+41
-6
lines changed

.github/workflows/continuous-deployment.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ jobs:
2424
steps:
2525
- name: Check out repository
2626
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
2729

2830
- name: Setup node
2931
uses: actions/setup-node@v4
@@ -39,12 +41,23 @@ jobs:
3941
run: |
4042
yarn run build
4143
44+
- name: Set up git environment
45+
run: |
46+
git config --global user.name "github-actions[bot]"
47+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
48+
4249
- name: Publish and tag releases
4350
run: |
4451
yarn run publish
4552
env:
4653
YARN_NPM_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
4754

55+
- name: Push tags to repository
56+
run: |
57+
git push --tags
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
4861
build-storybook:
4962
name: Build and deploy storybook
5063
runs-on: ubuntu-latest

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"status": "NODE_NO_WARNINGS=1 tsx scripts/publish-helpers status",
1313
"prepare": "NODE_NO_WARNINGS=1 tsx scripts/publish-helpers prepare",
1414
"publish": "NODE_NO_WARNINGS=1 tsx scripts/publish-helpers publish",
15+
"tag-versions": "NODE_NO_WARNINGS=1 tsx scripts/publish-helpers tag-versions",
1516
"publish:storybook": "./scripts/publish-storybook.sh",
1617
"format": "prettier --write .",
1718
"check-types": "tsc --noEmit",

scripts/publish-helpers/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* script to check versions on ui-packages and publish those that aren't on npm */
2-
import { runScript } from "./run-script";
2+
import { runScript, tagVersions } from "./run-script";
33
import { setupTerminal } from "./status";
44
import chalk from "chalk";
55

@@ -23,6 +23,8 @@ async function main() {
2323
await runScript({ build: true, publish: true }, modules);
2424
} else if (op === "build") {
2525
await runScript({ prepare: false, build: true, publish: false }, modules);
26+
} else if (op === "tag-versions") {
27+
tagVersions(modules);
2628
} else {
2729
console.log("Invalid operation. Use 'status', 'prepare', or 'publish'");
2830
}

scripts/publish-helpers/publish.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,23 @@ export function publishModule(pkg: PackageData) {
1111
cwd: pkg.directory,
1212
stdio: "inherit",
1313
});
14-
console.log(chalk.blueBright.bold("Tagging version"));
15-
const tag = moduleString(pkg, "-v");
16-
const msg = moduleString(pkg, " version ");
17-
execSync(`git tag -a ${tag} -m '${msg}'`, { cwd: pkg.directory });
14+
tagVersion(pkg);
1815
} catch (error) {
1916
console.error(`Failed to publish ${moduleString(pkg)}, ${error}`);
2017
}
2118
}
2219

20+
export function tagVersion(pkg: PackageData) {
21+
logAction(pkg, "Tagging", chalk.blue);
22+
const tag = moduleString(pkg, "-v");
23+
const msg = moduleString(pkg, " version ");
24+
try {
25+
execSync(`git tag -a ${tag} -m '${msg}'`, { cwd: pkg.directory });
26+
} catch (error) {
27+
console.error(`Failed to tag ${moduleString(pkg)}, ${error}`);
28+
}
29+
}
30+
2331
function moduleString(pkg, separator = "@") {
2432
return pkg["name"] + separator + pkg["version"];
2533
}

scripts/publish-helpers/run-script.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
getPackagePublicationStatus,
88
} from "./status";
99
import { prepareModule, ensureEntryFilesExist } from "./prepare";
10-
import { publishModule } from "./publish";
10+
import { publishModule, tagVersion } from "./publish";
1111

1212
export async function runScript(
1313
{ prepare = true, build = true, publish = true },
@@ -185,3 +185,14 @@ export async function runScript(
185185
publishModule(pkg);
186186
}
187187
}
188+
189+
export function tagVersions(modules: string[]) {
190+
const packages = getPackages("packages/*", "toolchain/*");
191+
for (const packageDir of packages) {
192+
const pkg = getPackageDataFromDirectory(packageDir);
193+
if (modules.length > 0 && !modules.includes(pkg.name)) {
194+
continue;
195+
}
196+
tagVersion(pkg);
197+
}
198+
}

0 commit comments

Comments
 (0)