skillhub/.github/scripts/git.ts
FenjuFu b17ddc3ff3 ci(reward): keep reward tags off Latest and out of git describe
reward-* tags pointed at PR merge commits and statistic-* tags at the
default branch HEAD, so they became the nearest tag in git describe for
later commits. statistic-* releases were also created without
--latest=false, so the GitHub API marked them as the Latest release.

- Point new reward-* / statistic-* tags at a parentless empty-tree commit
  (the merge commit SHA is kept in its message) so no branch reaches them;
  tag contents and dates are read as before
- Create statistic-* releases with --latest=false
- Drop the describe-based "new commits since last statistic" check, which
  cannot see detached tags; count-reward.ts already exits when there is
  no reward data for the previous month

Same fix as iflytek/astron-agent#1695.

Signed-off-by: FenjuFu <92919259+FenjuFu@users.noreply.github.com>
2026-10-03 20:16:06 +08:00

15 lines
639 B
TypeScript

import { $ } from "npm:zx";
/**
* Create a parentless commit with an empty tree to carry reward/statistic tags.
*
* Tags pointing at product commits become the nearest tag in `git describe`,
* so downstream builds would report versions like `reward-42-3-gabc1234`
* instead of the latest release tag. Tags on a detached commit are never
* reachable from any branch and keep release tags authoritative.
*/
export async function createDetachedCommit(message: string) {
const emptyTree = (await $`git hash-object -w -t tree /dev/null`).stdout.trim();
return (await $`git commit-tree ${emptyTree} -m ${message}`).stdout.trim();
}