diff --git a/.github/workflows/ai-service-build-image.yaml b/.github/workflows/ai-service-release-image.yaml similarity index 51% rename from .github/workflows/ai-service-build-image.yaml rename to .github/workflows/ai-service-release-image.yaml index 89721d54e..f4575ee82 100644 --- a/.github/workflows/ai-service-build-image.yaml +++ b/.github/workflows/ai-service-release-image.yaml @@ -1,16 +1,11 @@ -name: AI Service Build image +name: AI Service Release image on: workflow_dispatch: inputs: - docker_image_tag_name: + tag_name: description: Docker image tag name (Optional) type: string - is_latest: - description: Is latest (Optional) - type: boolean - required: false - default: false defaults: run: @@ -21,6 +16,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Prepare tag name + id: tag-preparation + run: | + if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then + tag_name=${{ github.event.inputs.tag_name }} + else + tag_name=commit-$(git log -1 --pretty=%h) + fi + echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -31,30 +35,12 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare tag name - id: tag-preparation - run: | - if [ -n "${{ github.event.inputs.docker_image_tag_name }}" ]; then - tag_name=${{ github.event.inputs.docker_image_tag_name }} - else - tag_name=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9]/-/g')-$(git log -1 --pretty=%h) - fi - echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT - name: Build and push image env: TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }} run: | - if [ ${{ github.event.inputs.is_latest }} == true ]; then - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/canner/wren-ai-service:$TAG_NAME \ - --tag ghcr.io/canner/wren-ai-service:latest \ - --file ./docker/Dockerfile \ - --push . - else - docker buildx build \ - --platform linux/amd64,linux/arm64 \ - --tag ghcr.io/canner/wren-ai-service:$TAG_NAME \ - --file ./docker/Dockerfile \ - --push . - fi + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag ghcr.io/canner/wren-ai-service:$TAG_NAME \ + --file ./docker/Dockerfile \ + --push . diff --git a/.github/workflows/ai-service-release-nightly-image.yaml b/.github/workflows/ai-service-release-nightly-image.yaml new file mode 100644 index 000000000..494e117a5 --- /dev/null +++ b/.github/workflows/ai-service-release-nightly-image.yaml @@ -0,0 +1,42 @@ +name: AI Service Release nightly image + +on: + push: + branches: [main] + paths: + - 'wren-ai-service/**' + +defaults: + run: + working-directory: wren-ai-service + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Prepare tag name + id: tag-preparation + run: | + tag_name=main-$(git log -1 --pretty=%h) + echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push image + env: + TAG_NAME: ${{ steps.tag-preparation.outputs.TAG_NAME }} + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag ghcr.io/canner/wren-ai-service:$TAG_NAME \ + --tag ghcr.io/canner/wren-ai-service:nightly \ + --file ./docker/Dockerfile \ + --push . diff --git a/.github/workflows/ai-service-release-stable-image.yaml b/.github/workflows/ai-service-release-stable-image.yaml new file mode 100644 index 000000000..baca994c3 --- /dev/null +++ b/.github/workflows/ai-service-release-stable-image.yaml @@ -0,0 +1,61 @@ +name: AI Service Release stable image + +on: + workflow_dispatch: + inputs: + version: + description: Give a version for this release + type: string + required: true + +defaults: + run: + working-directory: wren-ai-service + +jobs: + upgrade-ai-service-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Git + run: | + git config --global user.email "dev@cannerdata.com" + git config --global user.name "stable-release-bot" + - name: Set up Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: 3.12 + - name: Install Poetry + uses: abatilo/actions-poetry@v2 + with: + poetry-version: 1.7.1 + - name: Upgrade AI Service version + run: | + version=${{ github.event.inputs.version }} + poetry version --next-phase $version + git add pyproject.toml + git commit -m "Upgrade AI Service version to $version" + git push + build-image: + needs: upgrade-ai-service-version + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push image + run: | + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --tag ghcr.io/canner/wren-ai-service:${{ github.event.inputs.version }} \ + --tag ghcr.io/canner/wren-ai-service:latest \ + --file ./docker/Dockerfile \ + --push .