Skip to content

Commit 5601cec

Browse files
Refactor workflow to support multiple OS targets
1 parent 6b5bdc1 commit 5601cec

File tree

1 file changed

+55
-29
lines changed

1 file changed

+55
-29
lines changed

.github/workflows/package_and_push.yml

Lines changed: 55 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ run-name: 构建离线安装包 ${{ github.event.inputs.dockerImageTag }}
55
on:
66
workflow_dispatch:
77
inputs:
8+
target_os:
9+
description: 'Select OS to run on'
10+
required: false
11+
default: '["ubuntu-latest","ubuntu-24.04-arm"]'
12+
type: choice
13+
options:
14+
- '["ubuntu-latest"]'
15+
- '["ubuntu-24.04-arm"]'
16+
- '["ubuntu-latest","ubuntu-24.04-arm"]'
817
dockerImageTag:
918
description: 'Image Tag'
1019
default: 'v0.9.5'
@@ -17,16 +26,18 @@ on:
1726

1827
jobs:
1928
package-and-push-to-aliyun-oss:
20-
runs-on: ubuntu-latest
29+
runs-on: ${{ matrix.os }}
30+
strategy:
31+
matrix:
32+
os: ${{ fromJSON(inputs.target_os) }}
2133
steps:
2234
- name: Checkout
2335
uses: actions/checkout@v4
2436
with:
2537
ref: ${{ github.ref_name }}
2638
- name: Install ossutil
2739
run: |
28-
curl -L https://gosspublic.alicdn.com/ossutil/1.7.0/ossutil64 -o /usr/local/bin/ossutil
29-
chmod +x /usr/local/bin/ossutil
40+
curl https://gosspublic.alicdn.com/ossutil/install.sh | sh
3041
- name: Prepare package files
3142
env:
3243
TAG_NAME: ${{ github.event.inputs.dockerImageTag }}
@@ -53,6 +64,22 @@ jobs:
5364
5465
platform=""
5566
ARCH="x86_64"
67+
OS_type="$(uname -m)"
68+
case "$OS_type" in
69+
x86_64|amd64)
70+
ARCH='x86_64'
71+
platform=''
72+
;;
73+
aarch64|arm64)
74+
ARCH='aarch64'
75+
platform='-arm64'
76+
;;
77+
*)
78+
echo 'OS type not supported'
79+
exit 2
80+
;;
81+
esac
82+
5683
DOCKER_VERSION="docker-27.2.0"
5784
DOCKER_COMPOSE_VERSION="v2.29.2"
5885
@@ -65,24 +92,26 @@ jobs:
6592
wget https://resource-fit2cloud-com.oss-cn-hangzhou.aliyuncs.com/docker/docker.service
6693
mkdir docker/service && mv docker.service docker/service/
6794
68-
#打包离线包
69-
package_offline="sqlbot-offline-installer-${TAG_NAME}${platform}-ce.tar.gz"
70-
touch $package_offline
71-
tar --transform "s/^\./sqlbot-offline-installer-${TAG_NAME}${platform}-ce/" \
72-
--exclude $package_offline \
73-
--exclude .git \
74-
-czvf $package_offline .
75-
76-
#打包在线包
77-
package_online="sqlbot-online-installer-${TAG_NAME}${platform}-ce.tar.gz"
78-
touch $package_online
79-
tar --transform "s/^\./sqlbot-online-installer-${TAG_NAME}${platform}-ce/" \
80-
--exclude $package_online \
81-
--exclude $package_offline \
82-
--exclude .git \
83-
--exclude images \
84-
--exclude docker \
85-
-czvf $package_online .
95+
if [[ $ARCH == 'x86_64' ]]; then
96+
#打包离线包
97+
package_offline="sqlbot-offline-installer-${TAG_NAME}${platform}-ce.tar.gz"
98+
touch $package_offline
99+
tar --transform "s/^\./sqlbot-offline-installer-${TAG_NAME}${platform}-ce/" \
100+
--exclude $package_offline \
101+
--exclude .git \
102+
-czvf $package_offline .
103+
104+
#打包在线包
105+
package_online="sqlbot-online-installer-${TAG_NAME}${platform}-ce.tar.gz"
106+
touch $package_online
107+
tar --transform "s/^\./sqlbot-online-installer-${TAG_NAME}${platform}-ce/" \
108+
--exclude $package_online \
109+
--exclude $package_offline \
110+
--exclude .git \
111+
--exclude images \
112+
--exclude docker \
113+
-czvf $package_online .
114+
fi
86115

87116
if [[ ${PACKAGE_EE} == 'true' ]]; then
88117
package_offline_ee="sqlbot-offline-installer-${TAG_NAME}${platform}-ee.tar.gz"
@@ -96,13 +125,10 @@ jobs:
96125

97126
ossutil cp -rf ${package_offline_ee} oss://$ALIYUN_OSS_BUCKET/sqlbot/${package_offline_ee} --access-key-id=$ALIYUN_OSS_ACCESS_KEY --access-key-secret=$ALIYUN_OSS_ACCESS_SECRET --endpoint=${ALIYUN_OSS_BUCKET_ENDPOINT}
98127
fi
99-
100-
#Sync files to OSS
101-
ossutil cp -rf ${package_offline} oss://$ALIYUN_OSS_BUCKET/sqlbot/${package_offline} --access-key-id=$ALIYUN_OSS_ACCESS_KEY --access-key-secret=$ALIYUN_OSS_ACCESS_SECRET --endpoint=${ALIYUN_OSS_BUCKET_ENDPOINT}
102-
ossutil cp -rf ${package_online} oss://$ALIYUN_OSS_BUCKET/sqlbot/${package_online} --access-key-id=$ALIYUN_OSS_ACCESS_KEY --access-key-secret=$ALIYUN_OSS_ACCESS_SECRET --endpoint=${ALIYUN_OSS_BUCKET_ENDPOINT}
103-
104-
105-
106-
107128

129+
if [[ $ARCH == 'x86_64' ]]; then
130+
#Sync files to OSS
131+
ossutil cp -rf ${package_offline} oss://$ALIYUN_OSS_BUCKET/sqlbot/${package_offline} --access-key-id=$ALIYUN_OSS_ACCESS_KEY --access-key-secret=$ALIYUN_OSS_ACCESS_SECRET --endpoint=${ALIYUN_OSS_BUCKET_ENDPOINT}
132+
ossutil cp -rf ${package_online} oss://$ALIYUN_OSS_BUCKET/sqlbot/${package_online} --access-key-id=$ALIYUN_OSS_ACCESS_KEY --access-key-secret=$ALIYUN_OSS_ACCESS_SECRET --endpoint=${ALIYUN_OSS_BUCKET_ENDPOINT}
133+
fi
108134

0 commit comments

Comments
 (0)