Skip to content

Commit

Permalink
feat(packages/scripts): add force version support for tiup publish (#396
Browse files Browse the repository at this point in the history
)

Signed-off-by: wuhuizuo <[email protected]>

Signed-off-by: wuhuizuo <[email protected]>
  • Loading branch information
wuhuizuo committed Sep 3, 2024
1 parent 215e65b commit d2648de
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions packages/scripts/gen-delivery-tiup-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -eo pipefail
artifact_url="$1"
nightly="$2"
out_script="${3:-publish.sh}"
force_version="${4}"

# fetch artifact config
oras manifest fetch-config "$artifact_url" >artifact-config.json
Expand All @@ -15,21 +16,25 @@ fi
tiup_last_index=$(yq --output-format=yaml '.["net.pingcap.tibuild.tiup"] | length - 1' artifact-config.json)
os=$(yq --output-format=yaml '.["net.pingcap.tibuild.os"]' artifact-config.json)
architecture=$(yq --output-format=yaml '.["net.pingcap.tibuild.architecture"]' artifact-config.json)
version=$(yq --output-format=yaml '.["org.opencontainers.image.version"]' artifact-config.json)
if [ "$nightly" == "true" ]; then
# from vX.Y.Z-alpha-574-g75b451c454 => vX.Y.Z-alpha-nightly
version=$(echo "$version" | sed -E 's/\-[0-9]+-g[0-9a-f]+$//')
version="${version}-nightly"
fi
if [ "$force_version" != "" ]; then
version="$force_version"
else
version=$(yq --output-format=yaml '.["org.opencontainers.image.version"]' artifact-config.json)
if [ "$nightly" == "true" ]; then
# from vX.Y.Z-alpha-574-g75b451c454 => vX.Y.Z-alpha-nightly
version=$(echo "$version" | sed -E 's/\-[0-9]+-g[0-9a-f]+$//')
version="${version}-nightly"
fi

# GA case:
# when
# - the version is "vX.Y.Z-pre" and
# - the artifact_url has suffix: "vX.Y.Z_(linux|darwin)_(amd64|arm64)",
# then
# - set the version to "vX.Y.Z"
if [[ "$version" == v[0-9]*.[0-9]*.[0-9]*-pre && "$artifact_url" =~ .*:v[0-9]*.[0-9]*.[0-9]*_(linux|darwin)_(amd64|arm64)$ ]]; then
version="${version%-pre}"
# GA case:
# when
# - the version is "vX.Y.Z-pre" and
# - the artifact_url has suffix: "vX.Y.Z_(linux|darwin)_(amd64|arm64)",
# then
# - set the version to "vX.Y.Z"
if [[ "$version" == v[0-9]*.[0-9]*.[0-9]*-pre && "$artifact_url" =~ .*:v[0-9]*.[0-9]*.[0-9]*_(linux|darwin)_(amd64|arm64)$ ]]; then
version="${version%-pre}"
fi
fi

# generate the publish script.
Expand Down

0 comments on commit d2648de

Please sign in to comment.