From 14abef7cf0faba883912f30dc157054cf44d5c06 Mon Sep 17 00:00:00 2001 From: Isaac Jin Date: Fri, 11 Oct 2024 00:02:10 -0700 Subject: [PATCH] chore: refine CICD of publishing (#1040) --- .github/workflows/publish_docker_image.yml | 31 --------- .github/workflows/publish_release.yml | 81 ++++++++++++++++------ 2 files changed, 58 insertions(+), 54 deletions(-) delete mode 100644 .github/workflows/publish_docker_image.yml diff --git a/.github/workflows/publish_docker_image.yml b/.github/workflows/publish_docker_image.yml deleted file mode 100644 index d553babde..000000000 --- a/.github/workflows/publish_docker_image.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Publish Docker Image - -on: - release: - types: [ published ] - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GHCR - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GHCR_PACKAGE_PAT }} - - - name: Build and push Docker image - run: | - docker buildx build --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/camel-ai/camel:${{ github.ref_name }} \ - --sbom=false --provenance=false \ - --file .container/minimal_build/Dockerfile \ - --push . diff --git a/.github/workflows/publish_release.yml b/.github/workflows/publish_release.yml index 12adc1d5a..5892e93d9 100644 --- a/.github/workflows/publish_release.yml +++ b/.github/workflows/publish_release.yml @@ -1,4 +1,4 @@ -name: Publish camel to PyPI / GitHub +name: Publish CAMEL to PyPI / GitHub on: push: @@ -8,43 +8,78 @@ on: workflow_dispatch: jobs: - build-n-publish: + build-and-publish-pypi: name: Build and publish to PyPI runs-on: ubuntu-latest permissions: contents: write steps: - - uses: actions/checkout@v3 - - name: Build and publish to pypi + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build and publish to PyPI uses: JRubics/poetry-publish@v1.17 with: pypi_token: ${{ secrets.PYPI_API_KEY }} ignore_dev_requirements: "yes" - - name: Create GitHub Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token - with: - tag_name: ${{ github.ref }} - release_name: ${{ github.ref }} - draft: false - prerelease: false + create-release: + name: Create GitHub Release + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v4 - name: Get Asset name run: | export PKG=$(ls dist/ | grep tar) set -- $PKG echo "name=$1" >> $GITHUB_ENV - - name: Upload Release Asset (sdist) to GitHub - id: upload-release-asset - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release to GitHub + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + draft: false + prerelease: false + files: | + dist/${{ env.name }} + + build-and-publish-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and Push Docker image + uses: docker/build-push-action@v5 with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: dist/${{ env.name }} - asset_name: ${{ env.name }} - asset_content_type: application/zip + context: . + file: .container/minimal_build/Dockerfile + push: true + tags: | + ghcr.io/${{ github.repository }}:latest + ghcr.io/${{ github.repository }}:${{ github.ref_name }} + platforms: linux/amd64,linux/arm64 + sbom: false + provenance: false + labels: | + org.opencontainers.image.source=https://github.com/${{ github.repository }} + org.opencontainers.image.revision=${{ github.sha }}