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/08/12 09:31:41 UTC

(skywalking-java) branch fix/release-script-version-arg created (now 6a5c2a994a)

This is an automated email from the ASF dual-hosted git repository.

wu-sheng pushed a change to branch fix/release-script-version-arg
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git


      at 6a5c2a994a Identify the release by its tag, not the checked-out branch

This branch includes the following new commits:

     new 6a5c2a994a Identify the release by its tag, not the checked-out branch

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(skywalking-java) 01/01: Identify the release by its tag, not the checked-out branch

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wu-sheng pushed a commit to branch fix/release-script-version-arg
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git

commit 6a5c2a994a73f8c9b3d1de3eb843871ef4b5eae4
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Wed Aug 12 17:31:31 2026 +0800

    Identify the release by its tag, not the checked-out branch
    
    Every step after `prepare` derived the version from the working branch:
    
        version=$(git describe --tags --abbrev=0 | sed 's/^v//')
    
    Release tags are created on release/x.y.z and never become ancestors of main, so
    `git describe` cannot see them from main. By the time `vote-passed` runs - days
    later, after the release PR is merged and the branch auto-deleted - describe walks
    straight past every release tag to an unrelated ancient one, v3.2.6 in this
    repository. That is not a loud failure: `promote` would svn mv a 3.2.6 path, and
    `docker` would push apache/skywalking-java-agent:3.2.6-{alpine,java8,...} to
    Docker Hub under real version tags.
    
    The tag is the only thing that still pins a release once the branch is gone, and
    it is already what the rest of the flow acts on: release:perform builds from the
    tag, the source tar is cut from the tag, and the vote email quotes the tag's
    commit IDs. Resolve the version from the tag list too - branch-independent, and it
    outlives the release branch.
    
    resolve_version() takes an explicit argument, else $RELEASE_VERSION, else the
    highest vX.Y.Z tag. It validates the x.y.z shape and refuses to run when the tag
    does not exist, so a typo aborts instead of addressing a path that was never
    released. Wired into stage, upload, email, promote and docker, each of which now
    accepts an optional version argument; prepare-vote threads its version through
    explicitly rather than re-deriving it.
    
    vote-passed additionally prints what it is about to publish - tag, SVN move,
    Docker Hub tags, old version being removed - and asks for confirmation, since both
    destinations are public and awkward to walk back.
    
    Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
---
 docs/en/contribution/release-java-agent.md |   7 ++
 tools/releasing/release.sh                 | 117 +++++++++++++++++++++++------
 2 files changed, 102 insertions(+), 22 deletions(-)

diff --git a/docs/en/contribution/release-java-agent.md b/docs/en/contribution/release-java-agent.md
index 5b941a822c..f7a7ccb107 100644
--- a/docs/en/contribution/release-java-agent.md
+++ b/docs/en/contribution/release-java-agent.md
@@ -92,6 +92,13 @@ are found in `https://dist.apache.org/repos/dist/dev/skywalking/java-agent/x.y.z
 1. Check the Apache License Header. Run `docker run --rm -v $(pwd):/github/workspace apache/skywalking-eyes header check`. (No binaries in source codes)
 
 ## vote-passed
+Every step after `prepare` identifies the release by its **tag** (`vx.y.z`), never by the
+checked-out branch. By the time you run `vote-passed`, the release PR has normally been
+merged and `release/x.y.z` deleted, and `main` has already moved on to the next
+`-SNAPSHOT`; the tag is the only thing that still pins the release. The version defaults to
+the highest `vx.y.z` tag in the repository, and can be overridden with a positional
+argument (`./release.sh docker 9.7.0`) or `RELEASE_VERSION=9.7.0`.
+
 After the vote passes, run `vote-passed` which executes:
 1. **promote** — move packages from `dist/dev` to `dist/release` in Apache SVN (prompts for SVN credentials), then release the Nexus staging repository at https://repository.apache.org and update the website download page
 2. **docker** — build and push all Docker image variants (alpine, java8, java11, java17, java21, java25)
diff --git a/tools/releasing/release.sh b/tools/releasing/release.sh
index 22c200dc46..39e2e96954 100755
--- a/tools/releasing/release.sh
+++ b/tools/releasing/release.sh
@@ -46,6 +46,51 @@ info()  { echo -e "${GREEN}[INFO]${NC} $*"; }
 warn()  { echo -e "${YELLOW}[WARN]${NC} $*"; }
 error() { echo -e "${RED}[ERROR]${NC} $*"; exit 1; }
 
+# ============================================================
+# resolve_version — identify the release from its tag
+# ============================================================
+# Every step after `prepare` acts on the release tag, never on whatever branch
+# happens to be checked out. `release:perform` builds from the tag, the source
+# tar is cut from the tag, and the vote email quotes the tag's commit IDs.
+#
+# The version therefore has to be derived from the tag as well. `git describe`
+# cannot do this: release tags are created on release/x.y.z branches and never
+# become ancestors of main, so once the release PR is merged and the branch is
+# deleted, describe walks past them to an unrelated ancient tag (v3.2.6 here).
+# That would aim SVN moves and Docker pushes at the wrong version. Tags are
+# branch-independent and outlive the release branch, so select from the tag list.
+#
+# Order of precedence: explicit argument, then $RELEASE_VERSION, then the highest
+# vX.Y.Z tag in the repository.
+resolve_version() {
+    local explicit="${1:-}"
+    [ -z "$explicit" ] && explicit="${RELEASE_VERSION:-}"
+
+    local version
+    if [ -n "$explicit" ]; then
+        version="${explicit#v}"
+    else
+        local latest
+        latest=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -1)
+        if [ -z "$latest" ]; then
+            error "No vX.Y.Z release tag found. Pass the version explicitly, e.g. '$0 <command> 9.7.0'."
+        fi
+        version="${latest#v}"
+    fi
+
+    case "$version" in
+        [0-9]*.[0-9]*.[0-9]*) ;;
+        *) error "Version must look like x.y.z, got: ${version}" ;;
+    esac
+
+    # Refuse to act on a release that was never tagged.
+    if ! git rev-parse -q --verify "refs/tags/v${version}" >/dev/null 2>&1; then
+        error "Tag v${version} does not exist locally. Run '$0 prepare ${version}' first, or fetch it with 'git fetch origin --tags'."
+    fi
+
+    echo "$version"
+}
+
 # ============================================================
 # preflight — check tools and environment
 # ============================================================
@@ -249,12 +294,11 @@ EOF
 cmd_stage() {
     cd "$PROJECT_ROOT"
 
-    # Detect version from latest tag
     local version
-    version=$(git describe --tags --abbrev=0 | sed 's/^v//')
+    version=$(resolve_version "${1:-}")
     local tag_name="v${version}"
 
-    info "Staging release ${version}..."
+    info "Staging release ${version} (from tag ${tag_name})..."
 
     # Maven release:perform
     info "Running maven release:perform..."
@@ -320,7 +364,7 @@ cmd_upload() {
     cd "$PROJECT_ROOT"
 
     local version
-    version=$(git describe --tags --abbrev=0 | sed 's/^v//')
+    version=$(resolve_version "${1:-}")
     local svn_dev="https://dist.apache.org/repos/dist/dev/skywalking/java-agent"
 
     info "Uploading release ${version} to Apache SVN (dist/dev)..."
@@ -366,13 +410,13 @@ cmd_upload() {
 cmd_email() {
     local type="${1:-}"
     if [[ ! "$type" =~ ^(vote|announce)$ ]]; then
-        error "Usage: $0 email [vote|announce]"
+        error "Usage: $0 email <vote|announce> [version]"
     fi
 
     cd "$PROJECT_ROOT"
 
     local version
-    version=$(git describe --tags --abbrev=0 | sed 's/^v//')
+    version=$(resolve_version "${2:-}")
     local tag="v${version}"
     local commit_id
     commit_id=$(git rev-list -n1 "$tag" 2>/dev/null || echo "<GIT_COMMIT_ID>")
@@ -495,9 +539,9 @@ cmd_docker() {
     cd "$PROJECT_ROOT"
 
     local version
-    version=$(git describe --tags --abbrev=0 | sed 's/^v//')
+    version=$(resolve_version "${1:-}")
 
-    info "Building and pushing Docker images for ${version}..."
+    info "Building and pushing Docker images for ${version} (from tag v${version})..."
 
     local dist_tar="${SCRIPT_DIR}/${PRODUCT_NAME}-${version}/${PRODUCT_NAME}-${version}.tgz"
 
@@ -524,7 +568,7 @@ cmd_promote() {
     cd "$PROJECT_ROOT"
 
     local version
-    version=$(git describe --tags --abbrev=0 | sed 's/^v//')
+    version=$(resolve_version "${1:-}")
 
     info "Promoting release ${version} from dist/dev to dist/release..."
 
@@ -578,11 +622,11 @@ cmd_prepare_vote() {
     echo ""
     cmd_prepare "$version" "$next_version"
     echo ""
-    cmd_stage
+    cmd_stage "$version"
     echo ""
-    cmd_upload
+    cmd_upload "$version"
     echo ""
-    cmd_email vote
+    cmd_email vote "$version"
 }
 
 # ============================================================
@@ -591,11 +635,36 @@ cmd_prepare_vote() {
 cmd_vote_passed() {
     local old_version="${1:-}"
 
-    cmd_promote
+    cd "$PROJECT_ROOT"
+
+    # Resolved from the release tag, so this works after the release branch has
+    # been merged and deleted. Show it before touching SVN or Docker Hub, both of
+    # which are public and awkward to undo.
+    local version
+    version=$(resolve_version "")
+
+    info "Publishing release ${version}:"
+    echo "  Release tag     : v${version}"
+    echo "  SVN promote     : dist/dev/skywalking/java-agent/${version} -> dist/release/..."
+    echo "  Docker Hub tags : apache/skywalking-java-agent:${version}-{alpine,java8,java11,java17,java21,java25}"
+    if [ -n "$old_version" ]; then
+        echo "  Remove from SVN : dist/release/skywalking/java-agent/${old_version}"
+    else
+        echo "  Remove from SVN : (nothing - no old version given)"
+    fi
+    echo ""
+    read -rp "Continue? [y/N] " confirm
+    if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
+        info "Aborted."
+        exit 0
+    fi
+    echo ""
+
+    cmd_promote "$version"
     echo ""
-    cmd_docker
+    cmd_docker "$version"
     echo ""
-    cmd_email announce
+    cmd_email announce "$version"
 
     if [ -n "$old_version" ]; then
         echo ""
@@ -634,17 +703,21 @@ main() {
             echo "  (wait for 72h vote to pass)"
             echo "  $0 vote-passed [old_version]       # after vote"
             echo ""
+            echo "Every command after 'prepare' identifies the release by its tag (vX.Y.Z), not by the"
+            echo "checked-out branch, so they still work once release/x.y.z has been merged and deleted."
+            echo "The version defaults to the highest vX.Y.Z tag; override with an argument or RELEASE_VERSION."
+            echo ""
             echo "Individual commands:"
             echo "  preflight                     Check tools and environment"
             echo "  prepare <ver> [next_ver]      Prepare release (branch, tag, PR)"
-            echo "  stage                         Stage release (maven release:perform, build tars)"
-            echo "  upload                        Upload to Apache SVN dist/dev"
+            echo "  stage [ver]                   Stage release (maven release:perform, build tars)"
+            echo "  upload [ver]                  Upload to Apache SVN dist/dev"
             echo "  prepare-vote <ver> [next_ver] Run preflight + prepare + stage + upload + vote email"
-            echo "  email [vote|announce]  Generate email content"
-            echo "  promote                Move from dist/dev to dist/release in SVN"
-            echo "  docker                 Build and push Docker images"
-            echo "  vote-passed [old_ver]  Run promote + docker + announce email [+ cleanup]"
-            echo "  cleanup <old_version>  Remove old release from dist/release"
+            echo "  email <vote|announce> [ver]   Generate email content"
+            echo "  promote [ver]                 Move from dist/dev to dist/release in SVN"
+            echo "  docker [ver]                  Build and push Docker images to Docker Hub"
+            echo "  vote-passed [old_ver]         Run promote + docker + announce email [+ cleanup]"
+            echo "  cleanup <old_version>         Remove old release from dist/release"
             ;;
     esac
 }