Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: add cloud release ci and use ossutil to upload offline tar package. #4265

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/cloud-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Release Cloud

on:
release:
types: [ published ]

env:
# Common versions
GO_VERSION: "1.20"
DEFAULT_OWNER: "labring"

jobs:
save-sealos:
uses: ./.github/workflows/import-save-sealos.yml

release-controllers:
uses: ./.github/workflows/controllers.yml
with:
push_image: true
push_image_tag: ${{ github.event.release.tag_name }}
secrets: inherit

release-frontends:
uses: ./.github/workflows/frontend.yml
with:
push_image: true
push_image_tag: ${{ github.event.release.tag_name }}
secrets: inherit

release-service:
needs:
- save-sealos
uses: ./.github/workflows/services.yml
with:
push_image: true
push_image_tag: ${{ github.event.release.tag_name }}
secrets: inherit

release-cloud:
needs:
- save-sealos
- release-controllers
- release-frontends
- release-service
uses: ./.github/workflows/cloud.yml
with:
push_image: true
push_image_tag: ${{ github.event.release.tag_name }}
build_from: ${{ github.event.release.tag_name }}
secrets: inherit

release-offline-tar:
needs:
- release-cloud
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build
run: export CLOUD_VERSION=${{ github.event.release.tag_name }} && bash ./scripts/cloud/build-offline-tar.sh
- name: Setup ossutil
uses: manyuanrong/[email protected]
with:
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }}
- name: Cat md5sum
run: cat ./sealos-cloud.tar.gz.md5
- name: Upload
run: |
ossutil cp ./sealos-cloud.tar.gz oss://${{ secrets.OSS_BUCKET }}/cloud/sealos-cloud-${{ github.event.release.tag_name }}.tar.gz
ossutil cp ./sealos-cloud.tar.gz.md5 oss://${{ secrets.OSS_BUCKET }}/cloud/sealos-cloud-${{ github.event.release.tag_name }}.tar.gz.md5
23 changes: 17 additions & 6 deletions .github/workflows/cloud.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
name: Build Cloud Cluster image

on:
release:
types: [ published ]
workflow_run:
workflows: [ "Build Controllers image", "Build Frontend Image" ]
types:
- completed
workflow_call:
inputs:
push_image:
description: 'Push image'
required: false
type: boolean
default: false
push_image_tag:
description: 'Push all-in-one image tag, default is latest'
default: 'latest'
required: false
type: string
build_from:
description: 'Build all-in-one image from components image tag, default is latest'
default: 'latest'
required: false
type: string
workflow_dispatch:
inputs:
push_image:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/controllers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ name: Build Controllers image
on:
create:
tags:
workflow_call:
inputs:
push_image:
description: "Push image"
required: false
type: boolean
default: false
push_image_tag:
description: "Push image tag"
default: "latest"
required: false
type: string
workflow_dispatch:
inputs:
push_image:
Expand Down Expand Up @@ -50,6 +62,7 @@ jobs:
run: bash ./scripts/resolve-modules.sh ./controllers

golangci-lint:
if: ${{ github.event_name }} == 'push' || ${{ github.event_name }} == 'pull_request'
needs: [ resolve-modules ]
runs-on: ubuntu-20.04
strategy:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ name: Build Frontend Image
on:
create:
tags:
workflow_call:
inputs:
push_image:
description: "Push image"
required: false
type: boolean
default: false
push_image_tag:
description: "Push image tag"
default: "latest"
required: false
type: string
workflow_dispatch:
inputs:
push_image:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ name: Build Services image
on:
create:
tags:
workflow_call:
inputs:
push_image:
description: 'Push image'
required: false
type: boolean
default: false
push_image_tag:
description: 'Push image tag'
default: 'latest'
required: false
type: string
workflow_dispatch:
inputs:
push_image:
Expand Down
66 changes: 66 additions & 0 deletions scripts/cloud/build-offline-tar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash
set -x

CLOUD_VERSION="latest"

# pull and save images
mkdir -p output/tars

images=(
docker.io/labring/sealos-cloud:$CLOUD_VERSION
docker.io/labring/kubernetes:v1.25.6
docker.io/labring/helm:v3.12.0
docker.io/labring/cilium:v1.12.14
docker.io/labring/cert-manager:v1.8.0
docker.io/labring/openebs:v3.4.0
docker.io/labring/kubernetes-reflector:v7.0.151
docker.io/labring/ingress-nginx:v1.5.1
docker.io/labring/kubeblocks:v0.6.4
docker.io/labring/metrics-server:v0.6.4
)

for image in "${images[@]}"; do
sealos pull "$image"
filename=$(echo "$image" | cut -d':' -f1 | tr / -)
if [[ ! -f "output/tars/${filename}.tar" ]]; then
sealos save -o "output/tars/${filename}.tar" "$image"
fi
done


# get and save cli
mkdir -p output/cli

VERSION="v4.3.5"

wget https://github.com/labring/sealos/releases/download/${VERSION}/sealos_${VERSION#v}_linux_amd64.tar.gz \
&& tar zxvf sealos_${VERSION#v}_linux_amd64.tar.gz sealos && chmod +x sealos && mv sealos output/cli

# get and save install scripts
echo "
#!/bin/bash
bash scripts/load-images.sh
bash scripts/install.sh --cloud-version=$CLOUD_VERSION

" > output/install.sh

mkdir -p output/scripts

echo '
#!/bin/bash

for file in tars/*.tar; do
sealos load -i $file
done

cp cli/sealos /usr/local/bin
' > output/scripts/load-images.sh

curl -sfL https://raw.githubusercontent.com/labring/sealos/${CLOUD_VERSION}/scripts/cloud/install.sh -o output/scripts/install.sh

# tar output to a tar.gz
mv output sealos-cloud
tar czfv sealos-cloud.tar.gz sealos-cloud

# md5sum output tar.gz
md5sum sealos-cloud.tar.gz | cut -d " " -f1 > sealos-cloud.tar.gz.md5
Loading