You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/09/17 02:10:03 UTC
(skywalking-ai-sessionizer) branch main updated: Ask at publish whether a release becomes the latest (#16)
This is an automated email from the ASF dual-hosted git repository.
wu-sheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-ai-sessionizer.git
The following commit(s) were added to refs/heads/main by this push:
new ac0c114 Ask at publish whether a release becomes the latest (#16)
ac0c114 is described below
commit ac0c114d4efd884028269bf4d3ec25089ab1096e
Author: 吴晟 Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Sep 17 10:09:58 2026 +0800
Ask at publish whether a release becomes the latest (#16)
Promotion did not move GitHub's Latest label. CI creates the prerelease
with --latest=false, and publish promoted it with --prerelease=false
only, so the label stayed on the older release until someone moved it by
hand.
publish now asks, before anything moves, whether the version becomes the
latest release, and promotes with that answer. The answer offered is yes
for a version newer than every full release, and no otherwise, such as a
patch of an older line. --latest and --not-latest answer without asking.
An unclear answer, or both options, stops the command. A run after the
promotion refuses either option, because that run already decided.
The latest image tag now follows GitHub's latest release, so one answer
moves both. Before, the image job took the highest version on its own,
which could disagree with the label.
---
.github/workflows/ci.yaml | 21 ++++----
README.md | 2 +-
docs/en/changes/changes.md | 9 ++++
docs/en/guides/how-to-release.md | 18 +++++--
docs/en/setup/container-image.md | 6 ++-
tools/release.sh | 49 ++++++++++++++++---
tools/releasepublish/publish_test.go | 92 +++++++++++++++++++++++++++++++++++-
7 files changed, 172 insertions(+), 25 deletions(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 2f50258..dcdd034 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -401,8 +401,9 @@ jobs:
# A release is published under the version the tag names and
# nothing looser: no major.minor line, since a reader who
# pulls 0.2 cannot tell which release answered. latest is the
- # one floating tag, and it names the newest release only, so
- # promoting a patch of an older line must not drag it backwards.
+ # one floating tag. It follows GitHub's latest release, which
+ # tools/release.sh publish sets or leaves by asking the release
+ # manager, so a patch of an older line does not move it.
version="${ref#refs/tags/v}"
tags="$tags,$image:$version"
case "$version" in
@@ -410,15 +411,13 @@ jobs:
# A pre-release such as 0.2.0-rc1 moves no floating tag.
;;
*)
- # Candidate tags do not affect which approved release is latest.
- # The list is read on its own line: set -e stops the step
- # when gh fails, where the end of a pipeline would hide it
- # and publish the release without latest.
- released=$(gh api --method GET --paginate "repos/$GITHUB_REPOSITORY/releases" \
- --jq '.[] | select(.draft == false and .prerelease == false) | .tag_name')
- highest=$(printf '%s\n' "$released" | sed -nE '/^v[0-9]+\.[0-9]+\.[0-9]+$/p' | sort -Vr | head -1)
- [ -n "$highest" ] || { echo "::error::no published release found for the latest tag"; exit 1; }
- if [ "v$version" = "$highest" ]; then tags="$tags,$image:latest"; fi ;;
+ # Read on its own line: set -e stops the step when gh fails,
+ # where the end of a pipeline would hide it and publish the
+ # release without latest. The promotion sets the label in the
+ # same request that fires this event, so it is settled here.
+ latest=$(gh api --method GET "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)
+ [ -n "$latest" ] || { echo "::error::GitHub names no latest release"; exit 1; }
+ if [ "v$version" = "$latest" ]; then tags="$tags,$image:latest"; fi ;;
esac ;;
esac
echo "tags=$tags" >> "$GITHUB_OUTPUT"
diff --git a/README.md b/README.md
index 5f0db46..e1737dc 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,7 @@ docker run --rm -p 8787:8787 -v "$PWD/data:/asz/data" \
| Tag | Points at |
| --- | --- |
| `<version>`, such as `0.2.0` | the image built from the git tag `v<version>`, moved only by a run started by hand for that tag |
-| `latest` | the highest full published release version, once its GitHub prerelease is promoted after the Apache vote, or an explicit image retry publishes it |
+| `latest` | the version GitHub names its latest release, which the release manager decides when promoting it after the Apache vote |
| `main` | the development head |
| `<commit id>` | one commit, by its complete id, moved only by a run started by hand for a tag on it |
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 0c91f96..cfab648 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -71,3 +71,12 @@
- A scenario build writes `interval: 5s` into the configuration it creates, so a collector beside a
feed still picks up each session as it arrives. A directory an earlier build wrote without an
interval is brought up to date instead of refused.
+
+## Release
+
+- `publish` asks whether the version becomes the latest GitHub release before anything moves, and
+ promotes with that answer. Before, promotion left the Latest label on the older release, because
+ CI creates the prerelease with `--latest=false`. The answer offered is yes for a version newer
+ than every full release, and no for a patch of an older line. `--latest` and `--not-latest` answer
+ without asking. The `latest` image tag follows GitHub's latest release, so one decision moves
+ both. Before, the image took the highest version on its own.
diff --git a/docs/en/guides/how-to-release.md b/docs/en/guides/how-to-release.md
index d3c3dab..ec679de 100644
--- a/docs/en/guides/how-to-release.md
+++ b/docs/en/guides/how-to-release.md
@@ -666,6 +666,17 @@ It does these steps in order.
not one of the voted files. A missing prerelease, a missing CI file or a stray file stops the
command before anything moves. A full release is accepted too: an earlier `publish` promoted
it, and its files are checked again.
+
+ For a prerelease, it then asks whether `$VERSION` becomes the latest GitHub release. The label
+ also decides the `latest` image tag. The answer offered is yes when `$VERSION` is newer than
+ every full release, and no otherwise, such as for a patch of an older line or a version with a
+ suffix. `--latest` or `--not-latest` gives the answer without asking. Promotion does not move the
+ label by itself, because CI creates the prerelease with `--latest=false`. After promotion, the
+ label is changed only by hand, and `publish` refuses both options on a promoted release:
+
+ ```sh
+ gh release edit v$VERSION --repo apache/skywalking-ai-sessionizer --latest=true
+ ```
3. **Find the candidate:**
```sh
@@ -726,7 +737,7 @@ It does these steps in order.
```sh
gh release edit v$VERSION --repo apache/skywalking-ai-sessionizer --draft=false --prerelease=false \
- --title $VERSION --notes-file <text>
+ --latest=<the answer> --title $VERSION --notes-file <text>
```
The text is the tag's `docs/en/changes/changes.md` without its heading, followed by "Where to
@@ -777,8 +788,9 @@ the promotion, and `packages` runs each with `tools/package-smoke.sh` on a runne
platform.
The released event starts CI's `docker` job. That job publishes the container image to the
-GitHub container registry under `$VERSION`, and under `latest` when it is the highest version
-among full published GitHub releases. Newer candidate tags and prereleases do not affect `latest`.
+GitHub container registry under `$VERSION`, and under `latest` when GitHub names `v$VERSION` its
+latest release, as the answer in `publish` decided. Candidate tags and prereleases do not affect
+`latest`.
The image is a convenience built from the released source. The source and binary archive
release does not wait for the image job. If the image job fails, retry it on the release tag with `publish_image=true`:
diff --git a/docs/en/setup/container-image.md b/docs/en/setup/container-image.md
index afdc871..bbaff0f 100644
--- a/docs/en/setup/container-image.md
+++ b/docs/en/setup/container-image.md
@@ -24,7 +24,7 @@ after the Apache vote and distribution publication starts its build, as the tags
| Tag | Points at | Moves |
| --- | --- | --- |
| `<version>`, such as `0.2.0` | the image built from the git tag `v<version>` | only when a run started by hand publishes that tag again |
-| `latest` | the highest full published release version | when the GitHub prerelease is promoted after the Apache vote, or an explicit image retry publishes it |
+| `latest` | the version GitHub names its latest release | when a GitHub prerelease is promoted as the latest release after the Apache vote, or an explicit image retry publishes that version |
| `main` | the development head | on each push to `main` |
| `<commit id>` | one commit, by its complete 40-character id | only when a run started by hand publishes a tag on that commit again |
@@ -34,7 +34,9 @@ because a reader who pulls one cannot tell which version answered.
A git tag `v*` names a release candidate. CI on its push creates a GitHub prerelease holding the
binaries it built, for developer testing and local SVN staging. After the Apache vote passes,
`tools/release.sh publish` moves the approved files to the Apache release directory and promotes the
-prerelease to a full GitHub release, which publishes the image under that version.
+prerelease to a full GitHub release, which publishes the image under that version. It asks whether
+the version becomes the latest GitHub release, and only then does the image move `latest`. A patch
+of an older line is usually kept off it.
A draft or a prerelease publishes no container image. A manual image retry requires an existing
full GitHub release. A version with a suffix, such as
`0.2.0-rc1`, is published under its own version tag and under its commit id, because CI tags every
diff --git a/tools/release.sh b/tools/release.sh
index 5087418..995c61d 100755
--- a/tools/release.sh
+++ b/tools/release.sh
@@ -59,14 +59,18 @@
# dist/VERSION/vote-preview.txt. It refuses once a candidate of
# VERSION is uploaded.
#
-# tools/release.sh publish [VERSION] [--dry-run] [--remove-old]
+# tools/release.sh publish [VERSION] [--dry-run] [--remove-old] [--latest | --not-latest]
# Run by a PMC member after the vote passed. Verify the candidate's
# signatures against KEYS and move it from the dev area to the release
# directory of dist.apache.org. The move publishes the voted packages.
# With the vote and the announcement, it makes the release. Then check
# that the GitHub prerelease holds exactly the voted files, attach any
# that are missing, and promote it to a full release; CI publishes the
-# image when the released event fires. Then write the announcement,
+# image when the released event fires. Before anything moves, it asks
+# whether the version becomes the latest GitHub release, which also
+# moves the latest image tag. The answer offered is yes for a version
+# newer than every full release, and no for a patch of an older line.
+# --latest and --not-latest give the answer without asking. Then write the announcement,
# the website entries and the install manifests into dist/VERSION,
# and print what is left to do. A run after the move skips the move
# and runs every later step again. --remove-old removes older versions
@@ -95,7 +99,7 @@ cmd="${1:-}"
case "$cmd" in
prepare) options="--dry-run --skip-check --no-push" ;;
candidate) options="--dry-run --no-upload --ci-run" ;;
- publish) options="--dry-run --remove-old" ;;
+ publish) options="--dry-run --remove-old --latest --not-latest" ;;
-h|--help|"") usage; exit 0 ;;
*) echo "unknown command: $cmd" >&2; usage >&2; exit 2 ;;
esac
@@ -109,6 +113,7 @@ no_push=false
no_upload=false
ci_run=auto
remove_old=false
+latest=""
while [ $# -gt 0 ]; do
arg="$1"
shift
@@ -150,6 +155,9 @@ while [ $# -gt 0 ]; do
--no-push) no_push=true ;;
--no-upload) no_upload=true ;;
--remove-old) remove_old=true ;;
+ --latest|--not-latest)
+ [ -z "$latest" ] || { echo "give only one of --latest and --not-latest" >&2; exit 2; }
+ if [ "$arg" = --latest ]; then latest=true; else latest=false; fi ;;
esac ;;
*)
if [ -z "$version" ]; then version="$arg"
@@ -932,8 +940,36 @@ if [ "$cmd" = publish ]; then
if [ "$is_prerelease" = false ]; then
promoted=true
say "$tag is a full GitHub release already: an earlier publish promoted it. Its files are checked again"
+ # The run that promoted decided the label. A later run leaves it alone,
+ # and says so rather than ignoring the option.
+ [ -z "$latest" ] || fail "$tag was promoted by an earlier publish, which decided whether it is the latest release. Change the label by hand: gh release edit $tag --repo $release_repo --latest=<true or false>"
else
say "$tag is a GitHub prerelease, promoted after the move"
+ # Promotion does not move the Latest label by itself: CI created the
+ # prerelease with --latest=false. The label also decides the latest image
+ # tag, so it is a decision, asked before anything moves.
+ released=$(gh release list --repo "$release_repo" --limit 1000 --json tagName,isDraft,isPrerelease \
+ --jq '.[] | select((.isDraft or .isPrerelease) | not) | .tagName') \
+ || fail "cannot list the GitHub releases, to offer whether $tag becomes the latest. Nothing was moved"
+ newest=$(printf '%s\n' "$released" | sed -nE '/^v[0-9]+\.[0-9]+\.[0-9]+$/p' | sort -V | tail -1)
+ offered=no
+ case "$version" in
+ *-*) ;;
+ *)
+ if [ -z "$newest" ] || [ "$(printf '%s\n%s\n' "${newest#v}" "$version" | sort -V | tail -1)" = "$version" ]; then
+ offered=yes
+ fi ;;
+ esac
+ if [ -z "$latest" ]; then
+ answer=$(ask v "Mark $version as the latest GitHub release, which also moves the latest image tag? The latest now is ${newest:-none}. yes or no" "$offered")
+ case "$(printf '%s' "$answer" | tr '[:upper:]' '[:lower:]')" in
+ y|yes) latest=true ;;
+ n|no) latest=false ;;
+ *) fail "answer yes or no, not '$answer'. Nothing was moved" ;;
+ esac
+ fi
+ if [ "$latest" = true ]; then say "latest : $version becomes the latest GitHub release and the latest image"
+ else say "latest : ${newest:-no release} stays the latest; $version does not move the label or the latest image"; fi
fi
# Only names are checked here. The bytes are compared after the voted
# files are fetched, but a missing CI file or a stray asset is found now.
@@ -1022,7 +1058,7 @@ if [ "$cmd" = publish ]; then
say "- verify each package's signature against KEYS, before any move"
say "- check that the GitHub release $tag holds CI's binary packages and .sha512 files as voted, attach the voted source package, .sha512 and .asc files it is missing, and check that it holds exactly the voted files"
if [ "$promoted" = false ]; then
- say "- promote $tag to a full GitHub release, with the text of $dev_page in $tag; CI publishes the image on the released event"
+ say "- promote $tag to a full GitHub release, with the text of $dev_page in $tag, and --latest=$latest; CI publishes the image on the released event"
fi
say "- write the announcement to $out/announce.txt"
say "- write the website entries to $out/website.txt"
@@ -1096,9 +1132,10 @@ TEXT
release_text > "$scratch/notes.md"
current_info=$(release_identity) || fail "cannot read the GitHub release $tag again before promoting it. $resume_hint"
[ "$current_info" = "$release_info" ] || fail "the GitHub release $tag changed while publish was checking it, so it was not promoted. Find out why, then run publish again"
- gh release edit "$tag" --repo "$release_repo" --draft=false --prerelease=false --title "$version" --notes-file "$scratch/notes.md" \
+ gh release edit "$tag" --repo "$release_repo" --draft=false --prerelease=false --latest="$latest" --title "$version" --notes-file "$scratch/notes.md" \
|| fail "cannot promote the GitHub release $tag. $resume_hint"
- say "promoted $tag to a full GitHub release. CI publishes the image on the released event"
+ if [ "$latest" = true ]; then say "promoted $tag to the latest GitHub release. CI publishes the image, tagged latest too, on the released event"
+ else say "promoted $tag to a full GitHub release, not the latest. CI publishes the image under $version only, on the released event"; fi
fi
announce_mail() {
diff --git a/tools/releasepublish/publish_test.go b/tools/releasepublish/publish_test.go
index dc4eb46..c43bfac 100644
--- a/tools/releasepublish/publish_test.go
+++ b/tools/releasepublish/publish_test.go
@@ -41,6 +41,10 @@ type releaseState struct {
Interrupt bool `json:"interrupt"`
// Replace gives the release another ID once it has been downloaded.
Replace bool `json:"replace"`
+ // Released are the tags of the other full releases.
+ Released []string `json:"released"`
+ // Latest is the answer the promotion was given.
+ Latest string `json:"latest"`
}
type event struct {
@@ -189,8 +193,15 @@ func (f *fixture) events(action string) []event {
}
func (f *fixture) run(args ...string) (string, error) {
+ f.t.Helper()
+ return f.answer("", args...)
+}
+
+// answer runs publish with input as what the release manager types.
+func (f *fixture) answer(input string, args ...string) (string, error) {
f.t.Helper()
cmd := exec.Command("bash", append([]string{f.script, "publish", version}, args...)...)
+ cmd.Stdin = strings.NewReader(input)
cmd.Dir = f.dir
cmd.Env = append(os.Environ(), "PATH="+filepath.Join(f.dir, "bin")+string(os.PathListSeparator)+os.Getenv("PATH"), "RELEASE_PUBLISH_FIXTURE="+f.dir)
output, err := cmd.CombinedOutput()
@@ -440,6 +451,72 @@ func TestPublishNeedsNoLocalCandidate(t *testing.T) {
}
}
+// Promotion does not move GitHub's Latest label by itself, and the label
+// decides the latest image tag, so publish asks. The answer offered is yes
+// only for a version newer than every full release.
+func TestPublishAsksWhetherTheVersionBecomesLatest(t *testing.T) {
+ for _, tc := range []struct {
+ name, input string
+ released []string
+ args []string
+ latest string
+ }{
+ {name: "first-release", latest: "true"},
+ {name: "newest", released: []string{"v0.2.0", "v0.1.0"}, latest: "true"},
+ {name: "patch-of-an-older-line", released: []string{"v0.4.0", "v0.2.0"}, latest: "false"},
+ {name: "answered-no", input: "no\n", released: []string{"v0.2.0"}, latest: "false"},
+ {name: "answered-yes", input: "Y\n", released: []string{"v0.4.0"}, latest: "true"},
+ {name: "not-latest-option", released: []string{"v0.2.0"}, args: []string{"--not-latest"}, latest: "false"},
+ {name: "latest-option", released: []string{"v0.4.0"}, args: []string{"--latest"}, latest: "true"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ f := newFixture(t)
+ f.setState(releaseState{Exists: true, Prerelease: true, Released: tc.released})
+ if output, err := f.answer(tc.input, tc.args...); err != nil {
+ t.Fatalf("publish: %v\n%s", err, output)
+ }
+ f.requirePublished()
+ if got := f.state().Latest; got != tc.latest {
+ t.Fatalf("promoted with --latest=%s, want %s", got, tc.latest)
+ }
+ })
+ }
+}
+
+func TestPublishRefusesAnUnclearLatestAnswer(t *testing.T) {
+ t.Run("not-yes-or-no", func(t *testing.T) {
+ f := newFixture(t)
+ output, err := f.answer("maybe\n")
+ if err == nil || !strings.Contains(output, "answer yes or no") {
+ t.Fatalf("an unclear answer was accepted: %v\n%s", err, output)
+ }
+ f.requireNotMoved()
+ })
+ t.Run("both-options", func(t *testing.T) {
+ f := newFixture(t)
+ output, err := f.run("--latest", "--not-latest")
+ if err == nil || !strings.Contains(output, "only one of --latest and --not-latest") {
+ t.Fatalf("both options were accepted: %v\n%s", err, output)
+ }
+ f.requireNotMoved()
+ })
+ // The run that promoted decided the label, so a later run refuses to
+ // ignore the option and says how to change the label by hand.
+ t.Run("already-promoted", func(t *testing.T) {
+ f := newFixture(t)
+ if output, err := f.run(); err != nil {
+ t.Fatalf("publish: %v\n%s", err, output)
+ }
+ output, err := f.run("--not-latest")
+ if err == nil || !strings.Contains(output, "--latest=<true or false>") {
+ t.Fatalf("an option on a promoted release was accepted: %v\n%s", err, output)
+ }
+ if f.state().Latest != "true" || len(f.events("promote")) != 1 {
+ t.Fatal("the promoted release was changed")
+ }
+ })
+}
+
func contains(list []string, name string) bool {
for _, item := range list {
if item == name {
@@ -532,10 +609,18 @@ if tool == "svn":
raise AssertionError("unexpected svn command: " + repr(args))
sys.exit(0)
-assert tool == "gh" and args[:1] == ["release"] and args[2:5] == [tag, "--repo", "apache/skywalking-ai-sessionizer"], args
-action, rest = args[1], args[5:]
state_path = root / "state.json"
state = json.loads(state_path.read_text())
+if args[:2] == ["release", "list"]:
+ assert args[2:4] == ["--repo", "apache/skywalking-ai-sessionizer"] and "--json" in args, args
+ tags = list(state.get("released") or [])
+ if state["exists"] and not state["prerelease"]:
+ tags.append(tag)
+ for t in tags:
+ print(t)
+ sys.exit(0)
+assert tool == "gh" and args[:1] == ["release"] and args[2:5] == [tag, "--repo", "apache/skywalking-ai-sessionizer"], args
+action, rest = args[1], args[5:]
assets = root / "gh"
def save():
state_path.write_text(json.dumps(state))
@@ -580,8 +665,11 @@ elif action == "edit":
assert state["prerelease"], "promoted twice"
assert "--draft=false" in rest and "--prerelease=false" in rest and option("--title") == "0.3.0", rest
assert "Fixture release." in pathlib.Path(option("--notes-file")).read_text()
+ latest = [arg for arg in rest if arg.startswith("--latest=")]
+ assert len(latest) == 1 and latest[0] in ("--latest=true", "--latest=false"), rest
record("promote")
state["prerelease"] = False
+ state["latest"] = latest[0].split("=", 1)[1]
save()
else:
raise AssertionError("unexpected gh command: " + repr(args))