diff --git a/.github/workflows/package-apisix-rpm-el7.yml b/.github/workflows/package-apisix-rpm-el7.yml index f8393df63..587fe4a56 100644 --- a/.github/workflows/package-apisix-rpm-el7.yml +++ b/.github/workflows/package-apisix-rpm-el7.yml @@ -40,6 +40,7 @@ jobs: - name: packaging APISIX(-remote) with remote code run: | make package type=rpm app=apisix version=2.7 checkout=release/2.7 image_base=centos image_tag=7 artifact=apisix-remote + make package type=rpm app=apisix version=2.10.1 checkout=2.10.1 image_base=centos image_tag=7 artifact=apisix-remote make package type=rpm app=apisix version=master checkout=master image_base=centos image_tag=7 artifact=apisix-remote - name: packaging APISIX(-local) with local code @@ -56,12 +57,12 @@ jobs: docker exec centos7Instance bash -c "rpm --import https://repos.apiseven.com/KEYS" docker exec centos7Instance bash -c "yum -y install https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm" - - name: install APISIX(-remote) by rpm in container + - name: install APISIX(-remote) master by rpm in container run: | docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-remote-master-0.el7.x86_64.rpm" docker exec centos7Instance bash -c "apisix start" - - name: check and ensure APISIX(-remote) is installed + - name: check and ensure APISIX(-remote) master is installed run: | code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1') if [ ! $code -eq 200 ]; then @@ -69,11 +70,29 @@ jobs: exit 1 fi - - name: stop and uninstall APISIX(-remote) + - name: stop and uninstall APISIX(-remote) master run: | docker exec centos7Instance bash -c "pkill -f nginx" docker exec centos7Instance bash -c "yum -y erase apisix-remote-master" + - name: install APISIX(-remote) 2.10.1 by rpm in container + run: | + docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-remote-2.10.1-0.el7.x86_64.rpm" + docker exec centos7Instance bash -c "apisix start" + + - name: check and ensure APISIX(-remote) 2.10.1 is installed + run: | + code=$(curl -k -i -m 20 -o /dev/null -s -w %{http_code} http://127.0.0.1:9080/apisix/admin/routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1') + if [ ! $code -eq 200 ]; then + echo "failed: failed to install Apache APISIX by rpm" + exit 1 + fi + + - name: stop and uninstall APISIX(-remote) 2.10.1 + run: | + docker exec centos7Instance bash -c "pkill -f nginx" + docker exec centos7Instance bash -c "yum -y erase apisix-remote-2.10.1" + - name: install APISIX(-local) by rpm in container run: | docker exec centos7Instance bash -c "yum -y localinstall /output/apisix-local-master-0.el7.x86_64.rpm" diff --git a/utils/install-common.sh b/utils/install-common.sh index 7d0583e98..5fdf7c274 100755 --- a/utils/install-common.sh +++ b/utils/install-common.sh @@ -78,6 +78,19 @@ install_etcd() { tar -zxvf etcd-"${RUNNING_ETCD_VERSION}"-linux-amd64.tar.gz } +version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } + +is_newer_version() { + if [ "${checkout_v}" = "master" -o "${checkout_v:0:7}" = "release" ];then + return 0 + fi + if [ "${checkout_v:0:1}" = "v" ];then + version_gt "${checkout_v:1}" "2.2" + else + version_gt "${checkout_v}" "2.2" + fi +} + install_apisix() { # show awk version awk --version @@ -94,7 +107,7 @@ install_apisix() { cp /tmp/build/output/apisix/usr/local/apisix/deps/lib64/luarocks/rocks-5.1/apisix/master-${iteration}/bin/apisix /tmp/build/output/apisix/usr/bin/ || true cp /tmp/build/output/apisix/usr/local/apisix/deps/lib/luarocks/rocks-5.1/apisix/master-${iteration}/bin/apisix /tmp/build/output/apisix/usr/bin/ || true # modify the apisix entry shell to be compatible with version 2.2 and 2.3 - if [ "${checkout_v}" = "master" ] || [ "${checkout_v:0:1}" != "v" -a "${checkout_v}" \> "2.2" ] || [ "${checkout_v:0:1}" = "v" -a "${checkout_v:1}" \> "2.2" ]; then + if is_newer_version "${checkout_v}"; then echo 'use shell ' else bin='#! /usr/local/openresty/luajit/bin/luajit\npackage.path = "/usr/local/apisix/?.lua;" .. package.path' @@ -102,7 +115,7 @@ install_apisix() { fi cp -r /usr/local/apisix/* /tmp/build/output/apisix/usr/local/apisix/ mv /tmp/build/output/apisix/usr/local/apisix/deps/share/lua/5.1/apisix /tmp/build/output/apisix/usr/local/apisix/ - if [ "${checkout_v}" = "master" ] || [ "${checkout_v:0:1}" != "v" -a "${checkout_v}" \> "2.2" ] || [ "${checkout_v:0:1}" = "v" -a "${checkout_v:1}" \> "2.2" ]; then + if is_newer_version "${checkout_v}"; then bin='package.path = "/usr/local/apisix/?.lua;" .. package.path' sed -i "1s@.*@$bin@" /tmp/build/output/apisix/usr/local/apisix/apisix/cli/apisix.lua else