Skip to content

Commit

Permalink
ci: update steps/prepare_release.sh (#1086)
Browse files Browse the repository at this point in the history
  • Loading branch information
aceforeverd authored Jan 12, 2022
1 parent f7996e6 commit fd97d3d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: prepare release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=${VERSION#v}
bash steps/prepare_release.sh "$VERSION"
- name: build pysdk and sqlalchemy
run: |
make build
Expand Down
33 changes: 24 additions & 9 deletions steps/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/bash
#!/bin/bash

# Copyright 2021 4Paradigm
#
Expand All @@ -14,11 +14,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#
# prepare_release.sh
#
# support version syntax is X.Y.Z[.{pre-prelease-identifier}] where it could be:
# - semVer: X.Y.Z # final release
# - X.Y.Z.(a|alpha)N # alpha release
# - X.Y.Z.(b|beta)N # beta release
# - X.Y.Z.(r|rc)N # release candidate
# Note other version like 'X.Y.Z-rc1' may not work, don't use

GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'

set -ex
set -eE

cd "$(dirname "$0")/.."
ROOT=$(pwd)
Expand All @@ -27,9 +34,9 @@ cmake_file="$ROOT/CMakeLists.txt"
VERSION=$1
# shellcheck disable=SC2206
ARR=(${VERSION//./ })
echo "${ARR[*]}"
if [ "${#ARR[*]}" != 3 ]; then
echo "invalid version"
echo "splited version components: ${ARR[*]}"
if [[ "${#ARR[*]}" -lt 3 ]]; then
echo -e "${RED}inputed version should have at least three number${NC}"
exit 1
fi

Expand All @@ -42,5 +49,13 @@ sed -i"" -e "s/OPENMLDB_VERSION_MAJOR .*/OPENMLDB_VERSION_MAJOR ${MAJOR})/g" "${
sed -i"" -e "s/OPENMLDB_VERSION_MINOR .*/OPENMLDB_VERSION_MINOR ${MINOR})/g" "${cmake_file}"
sed -i"" -e "s/OPENMLDB_VERSION_BUG .*/OPENMLDB_VERSION_BUG ${BUG})/g" "${cmake_file}"

PY_VERSION=$VERSION
if [[ ${#ARR[@]} -gt 3 ]]; then
# has {pre-prelease-identifier}
# refer: https://www.python.org/dev/peps/pep-0440/#pre-releases
PY_VERSION="${ARR[0]}.${ARR[1]}.${ARR[2]}${ARR[3]}"
fi

# version in python sdk
sed -i"" -e "s/version=.*/version='$VERSION',/g" python/sqlalchemy-openmldb/setup.py
echo -e "${GREEN}setting py version to $PY_VERSION${NC}"
sed -i"" -e "s/version=.*/version='$PY_VERSION',/g" python/sqlalchemy-openmldb/setup.py

0 comments on commit fd97d3d

Please sign in to comment.