Skip to content

Commit

Permalink
add k3s
Browse files Browse the repository at this point in the history
  • Loading branch information
muicoder committed Sep 11, 2023
1 parent 176bbab commit 21c8b76
Show file tree
Hide file tree
Showing 5 changed files with 271 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/scripts/kubernetes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ readonly ERR_CODE=127

readonly ARCH=${arch?}
readonly CRI_TYPE=${criType?}
readonly KUBE_TYPE=${kubeType:-k8s}
readonly KUBE=${kubeVersion?}
readonly SEALOS=${sealoslatest?}

Expand All @@ -25,7 +26,7 @@ mkdir -p "$ROOT" "$PATCH"

cp -a "$CRI_TYPE"/* "$ROOT"
cp -a registry/* "$ROOT"
cp -a k8s/* "$ROOT"
cp -a "$KUBE_TYPE"/* "$ROOT"

# debug for sealos run
{
Expand Down
7 changes: 7 additions & 0 deletions .github/scripts/versions/versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

readonly CRI_TYPE=${criType?}
readonly KUBE_TYPE=${kubeType:-k8s}

readonly IMAGE_HUB_REGISTRY=${registry:-}
readonly IMAGE_HUB_REPO=${repo?}
Expand Down Expand Up @@ -66,6 +67,12 @@ for file in $(pwd)/.github/versions/${part:-*}/CHANGELOG*; do
until curl -sL "https://github.com/kubernetes/kubernetes/raw/master/CHANGELOG/$K8S_MD"; do sleep 3; done |
grep -E '^- \[v[0-9\.]+\]' | awk '{print $2}' | awk -F\[ '{print $2}' | awk -F\] '{print $1}' >".versions/$K8S_MD.cached"
head -n 1 ".versions/$K8S_MD.cached" >".versions/$K8S_MD.latest"
case $KUBE_TYPE in
k3s)
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^$(cat ".versions/$K8S_MD.latest")\+k3s[0-9]$" >".versions/$K8S_MD.cached"
cp ".versions/$K8S_MD.cached" ".versions/$K8S_MD.latest"
;;
esac
cat ".versions/$K8S_MD.cached"
)
[[ -s ".versions/$K8S_MD" ]] || cp ".versions/$K8S_MD.latest" ".versions/$K8S_MD"
Expand Down
7 changes: 7 additions & 0 deletions .github/scripts/versions/versions_arch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e

readonly CRI_TYPE=${criType?}
readonly KUBE_TYPE=${kubeType:-k8s}

readonly IMAGE_HUB_REGISTRY=${registry:-}
readonly IMAGE_HUB_REPO=${repo?}
Expand Down Expand Up @@ -66,6 +67,12 @@ for file in $(pwd)/.github/versions/${part:-*}/CHANGELOG*; do
until curl -sL "https://github.com/kubernetes/kubernetes/raw/master/CHANGELOG/$K8S_MD"; do sleep 3; done |
grep -E '^- \[v[0-9\.]+\]' | awk '{print $2}' | awk -F\[ '{print $2}' | awk -F\] '{print $1}' >".versions/$K8S_MD.cached"
head -n 1 ".versions/$K8S_MD.cached" >".versions/$K8S_MD.latest"
case $KUBE_TYPE in
k3s)
git ls-remote --refs --sort="-version:refname" --tags "https://github.com/k3s-io/k3s.git" | cut -d/ -f3- | grep -E "^$(cat ".versions/$K8S_MD.latest")\+k3s[0-9]$" >".versions/$K8S_MD.cached"
cp ".versions/$K8S_MD.cached" ".versions/$K8S_MD.latest"
;;
esac
cat ".versions/$K8S_MD.cached"
)
[[ -s ".versions/$K8S_MD" ]] || cp ".versions/$K8S_MD.latest" ".versions/$K8S_MD"
Expand Down
127 changes: 127 additions & 0 deletions .github/workflows/autobuild-k3s-containerd-part3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
name: containerd for k3s 1.24-25
on:
workflow_dispatch:
inputs:
sealosPatch:
description: 'sealos patch image for development.'
required: true
default: ghcr.io/labring/sealos-patch:latest
issue_comment:
types:
- created
env:
part: 3
allBuild: false
registry: ${{ vars.D_REGISTRY_NAME }}
repo: ${{ vars.D_REGISTRY_REPOSITORY }}
sealosPatch: ${{ github.event.inputs.sealosPatch }}
criType: containerd
kubeType: k3s
jobs:
resolve-issue-sealoslatest:
if: startswith(github.event.comment.body, '/kube') || startswith(github.event.comment.body, '/containerd') || startswith(github.event.comment.body, '/single_part3') || startswith(github.event.comment.body, '/single_containerd_part3') || contains(github.event.inputs.sealosPatch, 'sealos')
runs-on: ubuntu-20.04
outputs:
sealoslatest: ${{ steps.set-sealoslatest.outputs.sealoslatest }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set sealos LatestVersion
id: set-sealoslatest
run: |
export commentbody="${{github.event.comment.body}}"
.github/scripts/versions/versions_sealos.sh
resolve-versions-arch:
runs-on: ubuntu-20.04
needs:
- resolve-issue-sealoslatest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
outputs:
matrix: ${{ steps.set-versions.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Versions
id: set-versions
run: .github/scripts/versions/versions_arch.sh
resolve-versions:
runs-on: ubuntu-20.04
needs:
- resolve-issue-sealoslatest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
outputs:
matrix: ${{ steps.set-versions.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Versions
id: set-versions
run: .github/scripts/versions/versions.sh
build-images:
name: building
needs:
- resolve-issue-sealoslatest
- resolve-versions-arch
runs-on: ubuntu-20.04
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
strategy:
matrix: ${{ fromJson(needs.resolve-versions-arch.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download tools and sealos
run: .github/scripts/download.sh

- name: Auto build image
env:
username: ${{ vars.D_REGISTRY_REPOSITORY }}
password: ${{ secrets.D_REGISTRY_TOKEN }}
arch: ${{ matrix.arch }}
kubeVersion: ${{ matrix.version }}
run: .github/scripts/kubernetes.sh

build_manifest:
needs:
- resolve-issue-sealoslatest
- resolve-versions
- build-images
name: manifest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
strategy:
matrix: ${{ fromJson(needs.resolve-versions.outputs.matrix) }}
runs-on: ubuntu-20.04
permissions:
issues: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download tools and sealos
run: .github/scripts/download.sh
- name: Manifest Image
env:
username: ${{ vars.D_REGISTRY_REPOSITORY }}
password: ${{ secrets.D_REGISTRY_TOKEN }}
version: ${{ matrix.version }}-${{ env.sealoslatest }}
run: .github/scripts/manifest.sh
add-tips:
if: contains(github.event.comment.body, 'imagebuild')
needs:
- build_manifest
name: Auto add tips
runs-on: ubuntu-20.04
permissions:
issues: write
steps:
- name: Success Commit
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
� says: Hooray! The action autobuild-k8s-containerd-part3 has been completed successfully. �
See: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
128 changes: 128 additions & 0 deletions .github/workflows/autobuild-k3s-containerd-part4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: containerd for k3s 1.26+
on:
workflow_dispatch:
inputs:
sealosPatch:
description: 'sealos patch image for development.'
required: true
default: ghcr.io/labring/sealos-patch:latest
issue_comment:
types:
- created
env:
part: 4
allBuild: false
registry: ${{ vars.D_REGISTRY_NAME }}
repo: ${{ vars.D_REGISTRY_REPOSITORY }}
sealosPatch: ${{ github.event.inputs.sealosPatch }}
criType: containerd
kubeType: k3s
jobs:
resolve-issue-sealoslatest:
if: startswith(github.event.comment.body, '/kube') || startswith(github.event.comment.body, '/containerd') || startswith(github.event.comment.body, '/single_part4') || startswith(github.event.comment.body, '/single_containerd_part4') || contains(github.event.inputs.sealosPatch, 'sealos')
runs-on: ubuntu-20.04
outputs:
sealoslatest: ${{ steps.set-sealoslatest.outputs.sealoslatest }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set sealos LatestVersion
id: set-sealoslatest
run: |
export commentbody="${{github.event.comment.body}}"
.github/scripts/versions/versions_sealos.sh
resolve-versions-arch:
runs-on: ubuntu-20.04
needs:
- resolve-issue-sealoslatest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
outputs:
matrix: ${{ steps.set-versions.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Versions
id: set-versions
run: .github/scripts/versions/versions_arch.sh
resolve-versions:
runs-on: ubuntu-20.04
needs:
- resolve-issue-sealoslatest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
outputs:
matrix: ${{ steps.set-versions.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Resolve Versions
id: set-versions
run: .github/scripts/versions/versions.sh
build-images:
name: building
needs:
- resolve-issue-sealoslatest
- resolve-versions-arch
runs-on: ubuntu-20.04
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
strategy:
matrix: ${{ fromJson(needs.resolve-versions-arch.outputs.matrix) }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Download tools and sealos
run: .github/scripts/download.sh

- name: Auto build image
env:
username: ${{ vars.D_REGISTRY_REPOSITORY }}
password: ${{ secrets.D_REGISTRY_TOKEN }}
arch: ${{ matrix.arch }}
kubeVersion: ${{ matrix.version }}
run: .github/scripts/kubernetes.sh

build_manifest:
needs:
- resolve-issue-sealoslatest
- resolve-versions
- build-images
name: manifest
env:
sealoslatest: ${{ needs.resolve-issue-sealoslatest.outputs.sealoslatest }}
strategy:
matrix: ${{ fromJson(needs.resolve-versions.outputs.matrix) }}
runs-on: ubuntu-20.04
permissions:
issues: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download tools and sealos
run: .github/scripts/download.sh
- name: Manifest Image
env:
username: ${{ vars.D_REGISTRY_REPOSITORY }}
password: ${{ secrets.D_REGISTRY_TOKEN }}
version: ${{ matrix.version }}-${{ env.sealoslatest }}
run: .github/scripts/manifest.sh

add-tips:
if: contains(github.event.comment.body, 'imagebuild')
needs:
- build_manifest
name: Auto add tips
runs-on: ubuntu-20.04
permissions:
issues: write
steps:
- name: Success Commit
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.issue.number }}
body: |
🤖 says: Hooray! The action autobuild-k8s-containerd-part4 has been completed successfully. 🎉
See: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 comments on commit 21c8b76

Please sign in to comment.