Преглед на файлове

fix: pushing tags one by one on release

Karol Sójko преди 3 години
родител
ревизия
8837dca039
променени са 2 файла, в които са добавени 18 реда и са изтрити 1 реда
  1. 2 1
      package.json
  2. 16 0
      scripts/push-tags-one-by-one.sh

+ 2 - 1
package.json

@@ -38,7 +38,8 @@
     "start:files": "yarn workspace @standardnotes/files-server start",
     "start:files-worker": "yarn workspace @standardnotes/files-server worker",
     "start:api-gateway": "yarn workspace @standardnotes/api-gateway start",
-    "release:prod": "lerna version --conventional-graduate --conventional-commits --yes -m \"chore(release): publish new version\""
+    "release:prod": "lerna version --conventional-graduate --conventional-commits --yes -m \"chore(release): publish new version\"",
+    "postversion": "./scripts/push-tags-one-by-one.sh"
   },
   "devDependencies": {
     "@commitlint/cli": "^17.0.2",

+ 16 - 0
scripts/push-tags-one-by-one.sh

@@ -0,0 +1,16 @@
+#!/bin/bash
+# source: https://github.com/lerna/lerna/issues/2218#issuecomment-771876933
+# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
+# > "Note: An event will not be created when you create more than three tags at once."
+# GitHub workflows will not run if a commit includes more than 3 tags at once. This
+# fix pushes tags up one by one.
+
+# get all tags on this commit
+TAGS=$(git tag --points-at HEAD | cat)
+
+# only push tags one by one if there are more than 3
+if (($(echo "$TAGS"| wc -l) > 3))
+then
+  echo "Pushing tags one by one to avoid GitHub webhook limit of 3"
+  echo "$TAGS" | while read line ; do git push origin --no-follow-tags $line; done
+fi