Skip to content

Commit

Permalink
refactor: release ci
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Sep 4, 2024
1 parent bc1b857 commit 72f336f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 103 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ jobs:
run: make

- name: Run e2e tests
run: |
make deploy
kubectl rollout status deploy/kcl-webhook-server --timeout=1m
run: ./scripts/deploy_test.sh
100 changes: 2 additions & 98 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.11.2
version: v0.13.0
install: true

- name: Copy and edit amd4 arch for Dockerfile
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.11.2
version: v0.13.0
install: true

- name: Copy and edit amd4 arch for Dockerfile
Expand All @@ -93,99 +93,3 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

webhook-init-image-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.11.2
install: true

# <--- Login, build and push image to Docker Hub --->
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Copy and edit arm64 arch for Dockerfile
run: |
cp docker/amd64/Dockerfile.init Dockerfile
sed -i 's/kcllang/kcl-arm64\/kcllang/kcl/g' Dockerfile
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: kcllang/webhook-init-arm64
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

webhook-server-image-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: v0.11.2
install: true

# <--- Login, build and push image to Docker Hub --->
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Copy and edit arm64 arch for Dockerfile
run: |
cp docker/amd64/Dockerfile.server Dockerfile
sed -i 's/kcllang/kcl-arm64\/kcllang/kcl/g' Dockerfile
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: kcllang/webhook-server-arm64
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,7 @@ See [here](https://kcl-lang.io/docs/reference/lang/tour) to study more features
## Examples

See [here](https://github.com/kcl-lang/krm-kcl/tree/main/examples) for more examples.

git tag v0.1.0
git push origin v0.1.0
gh release create v0.1.0 --draft --generate-notes --title "v0.1.0 Release"
2 changes: 1 addition & 1 deletion docker/amd64/Dockerfile.init
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /

COPY . .

RUN GOOS=linux GOARCH=amd64 go build -o webhook-server cmd/wehbook-init
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o webhook-init cmd/wehbook-init

FROM kcllang/kcl

Expand Down
2 changes: 1 addition & 1 deletion docker/amd64/Dockerfile.server
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /

COPY . .

RUN GOOS=linux GOARCH=amd64 go build -o webhook-server cmd/wehbook-server
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o webhook-server cmd/wehbook-server

FROM kcllang/kcl

Expand Down
36 changes: 36 additions & 0 deletions scripts/deploy_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

make deploy
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m'

echo -e "${YELLOW}Monitoring deployment rollout status...${NC}"
kubectl rollout status deploy/kcl-webhook-server --timeout=1m
ROLLOUT_STATUS=$?

if [ $ROLLOUT_STATUS -ne 0 ]; then
echo -e "${RED}Deployment rollout failed.${NC}"

echo -e "${YELLOW}Retrieving deployment details...${NC}"
kubectl describe deploy/kcl-webhook-server

echo -e "${YELLOW}Retrieving ReplicaSet details...${NC}"
RS=$(kubectl get rs -l=app=kcl-webhook-server --output=jsonpath='{.items[*].metadata.name}')
for rs in $RS; do
echo -e "${YELLOW}ReplicaSet: $rs${NC}"
kubectl describe rs/$rs
done

echo -e "${YELLOW}Retrieving Pod details...${NC}"
PODS=$(kubectl get pods -l=app=kcl-webhook-server --output=jsonpath='{.items[*].metadata.name}')
for pod in $PODS; do
echo -e "${YELLOW}Pod: $pod${NC}"
kubectl describe pod/$pod
echo -e "${YELLOW}Pod logs:${NC}"
kubectl logs $pod
done
else
echo -e "${GREEN}Deployment rollout successful.${NC}"
fi

0 comments on commit 72f336f

Please sign in to comment.