@futurelastic/colab-handbook 1.14.0 → 1.14.1-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -33,5 +33,5 @@
33
33
  "engines": {
34
34
  "node": ">=18"
35
35
  },
36
- "version": "1.14.0"
36
+ "version": "1.14.1-rc.2"
37
37
  }
@@ -27,6 +27,8 @@
27
27
  # any of the above tagged something, and npm publish (job `npm`, #433) — candidates to
28
28
  # project.yml declares release.npm dist-tag `next`, finals to `latest`; see the
29
29
  # comment above that job
30
+ # the daily schedule or a dispatch, and the same npm publish of the newest final on main
31
+ # npm `latest` is older than that final — a final tagged by hand (`final: human`, #612)
30
32
  # the cut tagged a FINAL — route deploy + health check (job `deploy`, #446) — see
31
33
  # deploy-tag-fast only "DEPLOYING IN THIS RUN" below
32
34
  # the cut tagged a FINAL — route published like any tag (Release marked latest, npm
@@ -280,8 +282,8 @@ jobs:
280
282
  contents: write # push the tags (and, with promotion: main-loop, the promotion), publish the GitHub Release
281
283
  issues: write # finalize opens / comments on / closes the "release: vX.Y.Z" tracking issue
282
284
  actions: write # read the runs at a commit (ci-green, full-suite, trunk-green); dispatch CI after a promotion
283
- # What the npm job below needs (#433) — empty / publish=false unless this run tagged something
284
- # AND .github/project.yml opts in with release.npm.
285
+ # What the npm job below needs (#433) — empty / publish=false unless this run tagged something (or
286
+ # the daily sweep found a final npm lacks, #612) AND .github/project.yml opts in with release.npm.
285
287
  outputs:
286
288
  tags: ${{ steps.npm-target.outputs.tags }}
287
289
  npm: ${{ steps.npm-target.outputs.publish }}
@@ -635,11 +637,17 @@ jobs:
635
637
  # Whether the npm job publishes what this run tagged — `colab release npm` reads the
636
638
  # release: block (one reading, the same as cut/finalize). A CLI older than #433 gives no
637
639
  # verdict; that is a warning and no npm publish, never a failed release.
640
+ # #612: the daily run (and a dispatch) also hands on the newest FINAL reachable from main when
641
+ # npm `latest` is older — a final a person tagged (`final: human`) is never tagged by a run, so
642
+ # without this sweep it never reached npm. Already on npm, newer on npm, a private repo, or an
643
+ # unreadable registry: nothing is added.
638
644
  - name: Read the npm target (colab release npm) [publish]
639
645
  id: npm-target
640
- if: env.DRY_RUN != 'true' && (steps.cut.outputs.tag != '' || steps.finalize.outputs.tag != '')
646
+ if: env.DRY_RUN != 'true' && (steps.cut.outputs.tag != '' || steps.finalize.outputs.tag != '' || (github.event_name == 'schedule' && env.RETRY_RUN != 'true') || github.event_name == 'workflow_dispatch')
641
647
  env:
642
648
  TAGS: ${{ steps.cut.outputs.tag }} ${{ steps.finalize.outputs.tag }}
649
+ SWEEP: ${{ (github.event_name == 'schedule' && env.RETRY_RUN != 'true') || github.event_name == 'workflow_dispatch' }}
650
+ REPO: ${{ github.repository }}
643
651
  run: |
644
652
  set -uo pipefail
645
653
  OUT="$RUNNER_TEMP/npm.json"
@@ -656,12 +664,47 @@ jobs:
656
664
  echo "publish=false" >> "$GITHUB_OUTPUT"
657
665
  exit 0
658
666
  fi
667
+ TAGS="$(echo $TAGS)"
668
+ PACKAGE="$(jq -r '.package' "$OUT")"
669
+ # #612: a final tagged by hand. Only main's history counts (HEAD is main: this step never runs
670
+ # on a dry run), only a final (vX.Y.Z), only when npm `latest` is older or absent — so a version
671
+ # already published, or a newer one, is a no-op and `latest` never moves backwards.
672
+ if [ "${SWEEP:-false}" = "true" ]; then
673
+ eval "$RETRY_TRANSIENT"
674
+ FINAL="$(git tag --merged HEAD --list 'v*' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1)"
675
+ if [ -n "$FINAL" ] && ! grep -qxF "$FINAL" <<< "$(tr ' ' '\n' <<< "$TAGS")"; then
676
+ VERSION="${FINAL#v}"
677
+ PRIVATE="$(retry_transient gh api "repos/$REPO" --jq '.private' 2> /dev/null)" || PRIVATE=unknown
678
+ ERR="$RUNNER_TEMP/npm-latest.err"
679
+ if [ "$PRIVATE" != "false" ]; then
680
+ echo "npm sweep: $REPO is not public ($PRIVATE) — $FINAL is not handed to npm" | tee -a "$GITHUB_STEP_SUMMARY"
681
+ elif LATEST="$(retry_transient curl -fsSL "https://registry.npmjs.org/${PACKAGE/\//%2F}/latest" 2> "$ERR" | jq -r '.version // empty')" && [ -n "$LATEST" ]; then
682
+ if [ "$LATEST" = "$VERSION" ]; then
683
+ echo "npm sweep: $PACKAGE@$VERSION is already npm latest — nothing to publish"
684
+ elif [ "$(printf '%s\n' "$LATEST" "$VERSION" | sort -V | tail -n 1)" = "$LATEST" ]; then
685
+ echo "npm sweep: npm latest $PACKAGE@$LATEST is newer than $FINAL — nothing to publish" | tee -a "$GITHUB_STEP_SUMMARY"
686
+ else
687
+ TAGS="$(echo $TAGS $FINAL)"
688
+ echo "npm sweep: $FINAL is final on main but npm latest is $LATEST — handing it to the npm job (#612)" | tee -a "$GITHUB_STEP_SUMMARY"
689
+ fi
690
+ elif grep -q 'error: 404' "$ERR"; then
691
+ TAGS="$(echo $TAGS $FINAL)"
692
+ echo "npm sweep: $FINAL is final on main and $PACKAGE has no npm latest — handing it to the npm job (#612)" | tee -a "$GITHUB_STEP_SUMMARY"
693
+ else
694
+ echo "::warning::npm sweep: could not read npm latest for $PACKAGE ($(tail -n 1 "$ERR" 2> /dev/null)) — $FINAL is not handed on in this run; the next daily run retries"
695
+ fi
696
+ fi
697
+ fi
698
+ if [ -z "$TAGS" ]; then
699
+ echo "publish=false" >> "$GITHUB_OUTPUT"
700
+ exit 0
701
+ fi
659
702
  {
660
703
  echo "publish=true"
661
- echo "tags=$(echo $TAGS)"
704
+ echo "tags=$TAGS"
662
705
  echo "dir=$(jq -r '.dir' "$OUT")"
663
706
  echo "gate=$(jq -r '.gate' "$OUT")"
664
- echo "package=$(jq -r '.package' "$OUT")"
707
+ echo "package=$PACKAGE"
665
708
  } >> "$GITHUB_OUTPUT"
666
709
 
667
710
  # Publishes every tag THIS run created. In this run, never via a tag-push workflow:
@@ -709,7 +752,9 @@ jobs:
709
752
  done
710
753
 
711
754
  # ---------------------------------------------------------------------------------------------
712
- # npm (#433) — publishes what the release job tagged, in this same run. Opt-in: it runs only when
755
+ # npm (#433) — publishes what the release job tagged, in this same run — plus, on the daily run and a
756
+ # dispatch, the newest final on main that npm `latest` lacks: a final a person tagged by hand
757
+ # (`final: human`, #612), or one whose earlier publish failed. Opt-in: it runs only when
713
758
  # .github/project.yml declares release.npm + release.npm-gate on the public-tool route, so a repo
714
759
  # without them never gets this job.
715
760
  #
@@ -36,12 +36,28 @@ const squash = require('./squash.js');
36
36
  const branchNameLib = require('./branch-name.js');
37
37
  const { branchIssueNumbers } = branchNameLib;
38
38
 
39
- /** Every `#N` mentioned in any commit subject or body on the branch, de-duplicated. */
39
+ // The parenthesised keyword form `(issue N)` / `(issues N, M)` / `(issues N and M)` (#611). Some
40
+ // adopters write it instead of `#N` so that every commit does not cross-link into the issue's
41
+ // timeline; a group branch on such a repo had its second claimed issue refused as uncorroborated
42
+ // although four of its seven commits ended `(issue <that number>)`. The `issue` keyword is the
43
+ // whole point — a BARE number (`(42)`, `v1.2 (3 files)`) stays uncounted, so the #87 co-tenant
44
+ // guard is exactly as strong as before: a commit naming an issue this way names it as surely as
45
+ // `#N` does. Deliberately the parenthesised shape only, which is what was measured; a prose
46
+ // "see issue 12" is not a reference convention anyone was found writing.
47
+ const ISSUE_KEYWORD_GROUP = /\(\s*issues?\s+(#?\d+(?:\s*(?:,|&|\band\b)\s*#?\d+)*)\s*\)/gi;
48
+
49
+ /**
50
+ * Every issue a commit subject or body on the branch names, de-duplicated: each `#N`, plus each
51
+ * number inside an `(issue N)` / `(issues N, M)` group (#611).
52
+ */
40
53
  function commitIssueNumbers(commits) {
41
54
  const out = new Set();
42
55
  for (const c of Array.isArray(commits) ? commits : []) {
43
56
  const text = `${(c && c.subject) || ''}\n${(c && c.body) || ''}`;
44
57
  for (const m of text.matchAll(/#(\d+)\b/g)) out.add(Number(m[1]));
58
+ for (const m of text.matchAll(ISSUE_KEYWORD_GROUP)) {
59
+ for (const d of m[1].matchAll(/\d+/g)) out.add(Number(d[0]));
60
+ }
45
61
  }
46
62
  return [...out];
47
63
  }