micro--go-micro
f839ca7427
Rework `micro loop` so the workflows are the mechanism and each dispatch role's
instruction is an editable .github/loop/prompts/<role>.md file (the policy).
That split lets any repo — including go-micro itself — customize behavior by
editing prompt files instead of forking the CLI, which is the prerequisite for
go-micro consuming its own tool without losing its richer prompts.
- Add two opt-in roles: `coherence` (README/docs/CHANGELOG alignment) and
`release` (cut the next patch tag on new commits; bakes in the
persist-credentials:false fix so the PAT push isn't clobbered by the
checkout token — the 403 we hit on the live release action).
- `--roles` selects which roles to scaffold (default planner,builder,triage;
`all` for everything); `--tag-prefix`, `--release-cron`, `--coherence-cron`
added. Templates keep the << >> delimiters so GHA ${{ }} passes through;
prompts leave __ISSUE__/__RUNURL__ as runtime tokens the workflow substitutes.
- `micro loop verify` now checks each present role workflow has its prompt.
- README updated with the five roles and a copy-pasteable flag example
(folds in the readability fix from the now-closed #3651).
Verified: build, `go test ./cmd/micro/loop/...`, vet, golangci-lint (0 issues),
gofmt; and an end-to-end `micro loop init --roles all` whose generated
workflows all parse as valid YAML and pass `micro loop verify`.
Claude-Session: https://claude.ai/code/session_01CmdEY7pYmV5zzwCjNJ4ykL
Co-authored-by: Claude <noreply@anthropic.com>
77 行
2.8 KiB
Cheetah
77 行
2.8 KiB
Cheetah
name: "Loop: Release"
|
|
|
|
# Generated by `micro loop init`. Cuts the next PATCH tag
|
|
# (<< .TagPrefix >>MAJOR.MINOR.PATCH+1) when the default branch has new commits
|
|
# since the latest such tag, and pushes it with a PAT (<< .TokenSecret >>) so any
|
|
# tag-triggered release workflow fires. Minor/major bumps stay with a human.
|
|
#
|
|
# The tag MUST be pushed with a PAT, not the default GITHUB_TOKEN: a tag pushed
|
|
# by GITHUB_TOKEN does not trigger other workflows (Actions blocks that recursion).
|
|
|
|
on:
|
|
workflow_dispatch: {}
|
|
schedule:
|
|
- cron: "<< .ReleaseCron >>"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: loop-release
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # need full history + all tags
|
|
# Do NOT persist the default GITHUB_TOKEN as a git credential: it would
|
|
# be sent on the PAT push below and override it, so the tag push would
|
|
# authenticate as github-actions[bot] and 403. Letting the PAT in the
|
|
# push URL be the only credential is the whole point.
|
|
persist-credentials: false
|
|
- name: Cut the next patch tag if there are new commits
|
|
env:
|
|
RELEASE_TOKEN: ${{ secrets.<< .TokenSecret >> }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
if [ -z "$RELEASE_TOKEN" ]; then
|
|
echo "<< .TokenSecret >> is not set — skipping."
|
|
exit 0
|
|
fi
|
|
git fetch --tags --force
|
|
|
|
LATEST=$(git tag --list '<< .TagPrefix >>*.*.*' --sort=-v:refname | head -1)
|
|
if [ -z "$LATEST" ]; then
|
|
echo "no << .TagPrefix >>MAJOR.MINOR.PATCH tag found — aborting so nothing weird gets tagged."
|
|
exit 1
|
|
fi
|
|
echo "latest tag: $LATEST"
|
|
|
|
COUNT=$(git rev-list --count "$LATEST"..HEAD)
|
|
echo "commits since $LATEST: $COUNT"
|
|
if [ "$COUNT" -eq 0 ]; then
|
|
echo "no new commits since $LATEST — no release."
|
|
exit 0
|
|
fi
|
|
|
|
ver="${LATEST#<< .TagPrefix >>}"
|
|
major="${ver%%.*}"
|
|
rest="${ver#*.}"
|
|
minor="${rest%%.*}"
|
|
patch="${rest#*.}"
|
|
case "$major.$minor.$patch" in
|
|
[0-9]*.[0-9]*.[0-9]*) ;;
|
|
*) echo "unexpected tag shape: $LATEST" ; exit 1 ;;
|
|
esac
|
|
NEXT="<< .TagPrefix >>${major}.${minor}.$((patch + 1))"
|
|
echo "cutting: $NEXT ($COUNT commits since $LATEST)"
|
|
|
|
git config user.name "loop release bot"
|
|
git config user.email "noreply@users.noreply.github.com"
|
|
git tag -a "$NEXT" -m "Release $NEXT — automated patch ($COUNT commits since $LATEST)"
|
|
git push "https://x-access-token:${RELEASE_TOKEN}@github.com/${REPO}.git" "$NEXT"
|
|
echo "Pushed $NEXT."
|