Просмотр исходного кода

ci: publish with multiple tags instead of using dist-tag

npm dist-tag add command is broken, so publish package multiple times
with different tags directly instead
Dax Raad 2 месяцев назад
Родитель
Сommit
8e33ac052b
1 измененных файлов с 14 добавлено и 16 удалено
  1. 14 16
      packages/opencode/script/publish.ts

+ 14 - 16
packages/opencode/script/publish.ts

@@ -36,26 +36,24 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
   ),
 )
 
+const tags = [Script.channel]
+if (!Script.preview) {
+  const major = Script.version.split(".")[0]
+  tags.push(`latest-${major}`)
+}
+
 const tasks = Object.entries(binaries).map(async ([name]) => {
-  try {
-    if (process.platform !== "win32") {
-      await $`chmod 755 -R .`.cwd(`./dist/${name}`)
-    }
-    await $`bun pm pack`.cwd(`./dist/${name}`)
-    await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(`./dist/${name}`)
-  } finally {
+  if (process.platform !== "win32") {
+    await $`chmod 755 -R .`.cwd(`./dist/${name}`)
+  }
+  await $`bun pm pack`.cwd(`./dist/${name}`)
+  for (const tag of tags) {
+    await $`npm publish *.tgz --access public --tag ${tag}`.cwd(`./dist/${name}`)
   }
 })
 await Promise.all(tasks)
-await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel}`
-
-if (!Script.preview) {
-  const major = Script.version.split(".")[0]
-  const majorTag = `latest-${major}`
-  for (const [name] of Object.entries(binaries)) {
-    await $`cd dist/${name} && npm dist-tag add ${name}@${Script.version} ${majorTag}`
-  }
-  await $`cd ./dist/${pkg.name} && npm dist-tag add ${pkg.name}-ai@${Script.version} ${majorTag}`
+for (const tag of tags) {
+  await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${tag}`
 }
 
 if (!Script.preview) {