From 8dfa1ecbe688f488cbdd8e292c54b0a35288dc52 Mon Sep 17 00:00:00 2001 From: wanghe-fit2cloud Date: Fri, 19 Jan 2024 16:03:41 +0800 Subject: [PATCH] feat: modify release action --- .github/workflows/dev-workflow.yml | 42 -------------------------- .github/workflows/release-workflow.yml | 40 ------------------------ .github/workflows/release.yml | 38 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/dev-workflow.yml delete mode 100644 .github/workflows/release-workflow.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/dev-workflow.yml b/.github/workflows/dev-workflow.yml deleted file mode 100644 index fe142358..00000000 --- a/.github/workflows/dev-workflow.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Build dev package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - - build-and-push-to-dockerhub: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Prepare - id: prepare - run: | - DOCKER_IMAGE=kubeoperator/kubepi-server - DOCKER_PLATFORMS=linux/amd64 - TAG_NAME=${GITHUB_REF#refs/*/} - DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME}" - echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=version::${TAG_NAME} - echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ - --build-arg VERSION=${TAG_NAME} \ - --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ - --build-arg VCS_REF=${GITHUB_SHA::8} \ - ${DOCKER_IMAGE_TAGS} . - - name: Set up Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v3 - - name: Docker Buildx (build) - run: | - docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Docker Buildx (push) - run: | - docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml deleted file mode 100644 index 4ab00886..00000000 --- a/.github/workflows/release-workflow.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build production package - -on: - release: - types: [ published ] - -jobs: - - build-and-push-to-dockerhub: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Prepare - id: prepare - run: | - DOCKER_IMAGE=kubeoperator/kubepi-server - DOCKER_PLATFORMS=linux/amd64,linux/arm64 - TAG_NAME=${GITHUB_REF#refs/*/} - DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest" - echo ::set-output name=docker_image::${DOCKER_IMAGE} - echo ::set-output name=version::${TAG_NAME} - echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \ - --build-arg VERSION=${TAG_NAME} \ - --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ - --build-arg VCS_REF=${GITHUB_SHA::8} \ - ${DOCKER_IMAGE_TAGS} . - - name: Set up Docker Buildx - uses: crazy-max/ghaction-docker-buildx@v3 - - name: Docker Buildx (build) - run: | - docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }} - - name: Login to DockerHub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Docker Buildx (push) - run: | - docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2de702f2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Build Image + +on: + push: + tags: + - v* + +env: + DOCKERHUB_REPO: 1panel/kubepi + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Get Version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Build and Push + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: | + ${{ env.DOCKERHUB_REPO }}:latest + ${{ env.DOCKERHUB_REPO }}:${{ steps.get_version.outputs.VERSION }} \ No newline at end of file