Skip to content

Commit b4ea769

Browse files
authored
feat: add centos8 repo support (#181)
1 parent b5ccf73 commit b4ea769

File tree

5 files changed

+206
-16
lines changed

5 files changed

+206
-16
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: package apisix-base rpm for el8
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- "v*"
8+
paths-ignore:
9+
- '*.md'
10+
pull_request:
11+
branches: [ master ]
12+
paths-ignore:
13+
- '*.md'
14+
schedule:
15+
- cron: '0 0 * * *'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
env:
22+
BUILD_APISIX_BASE_VERSION: 1.19.3.2.0
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: install dependencies
27+
run: |
28+
sudo apt-get install -y make ruby ruby-dev rubygems build-essential
29+
30+
- name: build apisix-base rpm
31+
run: |
32+
make package type=rpm app=apisix-base version=${BUILD_APISIX_BASE_VERSION} image_base=centos image_tag=8
33+
34+
- name: run centos8 docker and mapping apisix-base rpm into container
35+
run: |
36+
docker run -itd -v /home/runner/work/apisix-build-tools/apisix-build-tools/output:/output --name centos8Instance --net="host" docker.io/centos:8 /bin/bash
37+
38+
- name: install dependencies in container
39+
run: |
40+
docker exec centos8Instance bash -c "sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*"
41+
docker exec centos8Instance bash -c "sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*"
42+
docker exec centos8Instance bash -c "dnf install -y centos-release-stream"
43+
docker exec centos8Instance bash -c "dnf swap -y centos-{linux,stream}-repos"
44+
docker exec centos8Instance bash -c "dnf distro-sync -y"
45+
46+
docker exec centos8Instance bash -c "dnf install -y yum-utils"
47+
docker exec centos8Instance bash -c "yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo"
48+
docker exec centos8Instance bash -c "yum -y install openresty-openssl111 openresty-pcre openresty-zlib"
49+
50+
- name: install rpm in container
51+
run: |
52+
docker exec centos8Instance bash -c "yum -y localinstall /output/apisix-base-${BUILD_APISIX_BASE_VERSION}-0.el8.x86_64.rpm"
53+
54+
- name: check and ensure apisix-base is installed
55+
run: |
56+
export APISIX_BASE_VER=$(docker exec centos8Instance bash -c "openresty -V" 2>&1 | awk '/-O2 -DAPISIX_BASE_VER=/{print $5}' | awk -v FS="=" '{print $2}')
57+
if [ "$APISIX_BASE_VER" != "${BUILD_APISIX_BASE_VERSION}" ]; then exit 1; fi
58+
59+
- name: Publish Artifact
60+
uses: actions/[email protected]
61+
with:
62+
name: apisix-base-${{ env.BUILD_APISIX_BASE_VERSION }}-0.el8.x86_64.rpm
63+
path: output/apisix-base-${{ env.BUILD_APISIX_BASE_VERSION }}-0.el8.x86_64.rpm
64+
retention-days: 5
65+
if-no-files-found: error
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: package apisix rpm for el8
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags:
7+
- "v*"
8+
paths-ignore:
9+
- '*.md'
10+
pull_request:
11+
branches: [ master ]
12+
paths-ignore:
13+
- '*.md'
14+
schedule:
15+
- cron: '0 0 * * *'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
services:
22+
etcd:
23+
image: bitnami/etcd:3.4.0
24+
ports:
25+
- 2379:2379
26+
- 2380:2380
27+
env:
28+
ALLOW_NONE_AUTHENTICATION: yes
29+
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
30+
31+
steps:
32+
- uses: actions/checkout@v2
33+
34+
- name: install dependencies
35+
run: |
36+
sudo apt-get install -y make ruby ruby-dev rubygems build-essential
37+
sudo gem install --no-document fpm
38+
sudo apt-get install -y rpm
39+
40+
- name: packaging APISIX(-remote) with remote code
41+
run: |
42+
make package type=rpm app=apisix version=2.7 checkout=release/2.7 image_base=centos image_tag=8 artifact=apisix-remote
43+
make package type=rpm app=apisix version=2.10.1 checkout=2.10.1 image_base=centos image_tag=8 artifact=apisix-remote
44+
make package type=rpm app=apisix version=master checkout=master image_base=centos image_tag=8 artifact=apisix-remote
45+
46+
- name: packaging APISIX(-local) with local code
47+
run: |
48+
git clone https://github.com/apache/apisix.git
49+
make package type=rpm app=apisix version=master checkout=master image_base=centos image_tag=8 local_code_path=./apisix artifact=apisix-local
50+
51+
- name: run centos8 docker and mapping rpm into container
52+
run: |
53+
docker run -itd -v $PWD/output:/output --name centos8Instance --net="host" docker.io/centos:8 /bin/bash
54+
docker exec centos8Instance bash -c "sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*"
55+
docker exec centos8Instance bash -c "sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-Linux-*"
56+
docker exec centos8Instance bash -c "dnf install -y centos-release-stream"
57+
docker exec centos8Instance bash -c "dnf swap -y centos-{linux,stream}-repos"
58+
docker exec centos8Instance bash -c "dnf distro-sync -y"
59+
60+
- name: enable apisix repository in container
61+
run: |
62+
docker exec centos8Instance bash -c "rpm --import https://repos.apiseven.com/KEYS"
63+
docker exec centos8Instance bash -c "yum -y install https://repos.apiseven.com/packages/centos/apache-apisix-repo-1.0-1.noarch.rpm"
64+
65+
- name: install APISIX(-remote) master by rpm in container
66+
run: |
67+
docker exec centos8Instance bash -c "yum -y localinstall /output/apisix-remote-master-0.el8.x86_64.rpm"
68+
docker exec centos8Instance bash -c "apisix start"
69+
70+
- name: check and ensure APISIX(-remote) master is installed
71+
run: |
72+
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')
73+
if [ ! $code -eq 200 ]; then
74+
echo "failed: failed to install Apache APISIX by rpm"
75+
exit 1
76+
fi
77+
78+
- name: stop and uninstall APISIX(-remote) master
79+
run: |
80+
docker exec centos8Instance bash -c "pkill -f nginx"
81+
docker exec centos8Instance bash -c "yum -y erase apisix-remote-master"
82+
83+
- name: install APISIX(-remote) 2.10.1 by rpm in container
84+
run: |
85+
docker exec centos8Instance bash -c "yum -y localinstall /output/apisix-remote-2.10.1-0.el8.x86_64.rpm"
86+
docker exec centos8Instance bash -c "apisix start"
87+
88+
- name: check and ensure APISIX(-remote) 2.10.1 is installed
89+
run: |
90+
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')
91+
if [ ! $code -eq 200 ]; then
92+
echo "failed: failed to install Apache APISIX by rpm"
93+
exit 1
94+
fi
95+
96+
- name: stop and uninstall APISIX(-remote) 2.10.1
97+
run: |
98+
docker exec centos8Instance bash -c "pkill -f nginx"
99+
docker exec centos8Instance bash -c "yum -y erase apisix-remote-2.10.1"
100+
101+
- name: install APISIX(-local) by rpm in container
102+
run: |
103+
docker exec centos8Instance bash -c "yum -y localinstall /output/apisix-local-master-0.el8.x86_64.rpm"
104+
docker exec centos8Instance bash -c "apisix start"
105+
106+
- name: check and ensure APISIX(-local) is installed
107+
run: |
108+
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')
109+
if [ ! $code -eq 200 ]; then
110+
echo "failed: failed to install Apache APISIX by rpm"
111+
exit 1
112+
fi

.github/workflows/publish.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ jobs:
5454
run: |
5555
# build apisix
5656
make package type=rpm app=apisix openresty=apisix-base checkout=${APISIX_TAG_VERSION} version=${APISIX_TAG_VERSION} image_base=centos image_tag=7
57-
mv ./output/apisix-${APISIX_TAG_VERSION}-0.el7.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
57+
make package type=rpm app=apisix openresty=apisix-base checkout=${APISIX_TAG_VERSION} version=${APISIX_TAG_VERSION} image_base=centos image_tag=8
58+
mv ./output/apisix-${APISIX_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
5859
echo "TARGET_APP=apisix" >> "$GITHUB_ENV"
5960
6061
- name: Build apisix-base RPM Package
@@ -66,7 +67,8 @@ jobs:
6667
echo ${{ steps.tag_env.outputs.version}}
6768
echo ${{ steps.tag_type.outputs.version}}
6869
make package type=rpm app=apisix-base checkout=${APISIX_BASE_TAG_VERSION} version=${APISIX_BASE_TAG_VERSION} image_base=centos image_tag=7
69-
mv ./output/apisix-base-${APISIX_BASE_TAG_VERSION}-0.el7.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
70+
make package type=rpm app=apisix-base checkout=${APISIX_BASE_TAG_VERSION} version=${APISIX_BASE_TAG_VERSION} image_base=centos image_tag=8
71+
mv ./output/apisix-base-${APISIX_BASE_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
7072
echo "TARGET_APP=apisix-base" >> "$GITHUB_ENV"
7173
7274
- name: Build apisix-dashboard RPM Package
@@ -76,7 +78,8 @@ jobs:
7678
run: |
7779
# build apisix dashboard
7880
make package type=rpm app=dashboard checkout=${APISIX_DASHBOARD_TAG_VERSION} version=${APISIX_DASHBOARD_TAG_VERSION} image_base=centos image_tag=7
79-
mv ./output/apisix-dashboard-${APISIX_DASHBOARD_TAG_VERSION}-0.el7.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
81+
make package type=rpm app=dashboard checkout=${APISIX_DASHBOARD_TAG_VERSION} version=${APISIX_DASHBOARD_TAG_VERSION} image_base=centos image_tag=8
82+
mv ./output/apisix-dashboard-${APISIX_DASHBOARD_TAG_VERSION}-0.el{7,8}.x86_64.rpm ${VAR_RPM_WORKBENCH_DIR}
8083
echo "TARGET_APP=apisix-dashboard" >> "$GITHUB_ENV"
8184
8285
- name: Upload apisix Artifact

utils/build-common.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,20 @@ ARCH=${ARCH:-`(uname -m | tr '[:upper:]' '[:lower:]')`}
66
BUILD_PATH=${BUILD_PATH:-`pwd`}
77

88
build_apisix_base_rpm() {
9-
yum -y install centos-release-scl
10-
yum -y install devtoolset-9 patch wget git make sudo
11-
set +eu
12-
source scl_source enable devtoolset-9
13-
set -eu
9+
if [[ $(rpm --eval '%{centos_ver}') == "7" ]]; then
10+
yum -y install centos-release-scl
11+
yum -y install devtoolset-9 patch wget git make sudo
12+
set +eu
13+
source scl_source enable devtoolset-9
14+
set -eu
15+
elif [[ $(rpm --eval '%{centos_ver}') == "8" ]]; then
16+
dnf install -y gcc-toolset-9-toolchain patch wget git make sudo
17+
dnf install -y yum-utils
18+
set +eu
19+
source /opt/rh/gcc-toolset-9/enable
20+
set -eu
21+
fi
22+
1423
command -v gcc
1524
gcc --version
1625

utils/install-common.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ install_dependencies_rpm() {
1818
# install basic dependencies
1919
yum -y install wget tar gcc automake autoconf libtool make curl git which unzip sudo
2020
yum -y install epel-release
21-
yum install -y yum-utils readline-dev readline-devel
21+
yum install -y yum-utils readline-devel
2222
}
2323

2424
install_dependencies_deb() {
@@ -59,13 +59,14 @@ version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1";
5959

6060
is_newer_version() {
6161
if [ "${checkout_v}" = "master" -o "${checkout_v:0:7}" = "release" ];then
62-
return 0
63-
fi
64-
if [ "${checkout_v:0:1}" = "v" ];then
65-
version_gt "${checkout_v:1}" "2.2"
66-
else
67-
version_gt "${checkout_v}" "2.2"
68-
fi
62+
return 0
63+
fi
64+
65+
if [ "${checkout_v:0:1}" = "v" ];then
66+
version_gt "${checkout_v:1}" "2.2"
67+
else
68+
version_gt "${checkout_v}" "2.2"
69+
fi
6970
}
7071

7172
install_apisix() {

0 commit comments

Comments
 (0)