diff --git a/.github/workflows/ai-service-release-image.yaml b/.github/workflows/ai-service-release-image.yaml index a7ba93478..cbf7bab4e 100644 --- a/.github/workflows/ai-service-release-image.yaml +++ b/.github/workflows/ai-service-release-image.yaml @@ -24,7 +24,7 @@ jobs: else tag_name=commit-$(git log -1 --pretty=%h) fi - echo "TAG_NAME=$tag_name" >> $GITHUB_OUTPUT + echo "TAG_NAME=$tag_name" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -35,12 +35,18 @@ jobs: 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 \ - --file ./docker/Dockerfile \ - --push . + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/canner/wren-ai-service + tags: | + type=raw,${{ env.TAG_NAME }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + context: ./wren-ai-service + file: ./wren-ai-service/docker/Dockerfile \ No newline at end of file diff --git a/.github/workflows/ai-service-release-nightly-image.yaml b/.github/workflows/ai-service-release-nightly-image.yaml index 494e117a5..d9afdc2f4 100644 --- a/.github/workflows/ai-service-release-nightly-image.yaml +++ b/.github/workflows/ai-service-release-nightly-image.yaml @@ -30,13 +30,19 @@ jobs: 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 . + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/canner/wren-ai-service + tags: | + type=raw,${{ env.TAG_NAME }} + type=raw,nightly + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + context: ./wren-ai-service + file: ./wren-ai-service/docker/Dockerfile \ No newline at end of file diff --git a/.github/workflows/ai-service-release-stable-image.yaml b/.github/workflows/ai-service-release-stable-image.yaml index b6d88b02d..f33b2d062 100644 --- a/.github/workflows/ai-service-release-stable-image.yaml +++ b/.github/workflows/ai-service-release-stable-image.yaml @@ -25,6 +25,7 @@ jobs: - uses: actions/checkout@v4 with: token: ${{ steps.generate-token.outputs.token }} + fetch-depth: 0 - name: Set up Git run: | git config --global user.name "wren-ai[bot]" @@ -37,6 +38,32 @@ jobs: uses: abatilo/actions-poetry@v2 with: poetry-version: 1.8.3 + - name: Generate and Save Change Log + id: changelog + run: | + echo "Generating change log..." + PREVIOUS_VERSION=release/ai-service/$(poetry version -s) + echo "Previous version: $PREVIOUS_VERSION" + CHANGE_LOG=$(git log --pretty=format:"%s" $PREVIOUS_VERSION..HEAD | grep wren-ai-service) + + # Separate the change log into categories + FEATURES=$(echo "$CHANGE_LOG" | grep "^feat" | sed 's/^/- /') + FIXES_AND_CHORES=$(echo "$CHANGE_LOG" | grep -E "^(fix|chore)" | sed 's/^/- /') + + # Create the full change log + FULL_CHANGE_LOG="\nChangelog for the version\n" + if [ -n "$FEATURES" ]; then + FULL_CHANGE_LOG+="\nFeature and Enhancement\n$FEATURES" + fi + if [ -n "$FIXES_AND_CHORES" ]; then + FULL_CHANGE_LOG+="\n\nFixes and Chores\n$FIXES_AND_CHORES" + fi + + { + echo "CHANGE_LOG<> $GITHUB_ENV - name: Upgrade AI Service version run: | version=${{ github.event.inputs.version }} @@ -44,6 +71,8 @@ jobs: git add pyproject.toml git commit -m "Upgrade AI Service version to $version" git push + git tag -a "release/ai-service/$version" -m "${{ env.CHANGE_LOG }}" + git push origin "release/ai-service/$version" build-image: needs: upgrade-ai-service-version runs-on: ubuntu-latest @@ -59,11 +88,19 @@ jobs: 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 . + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/canner/wren-ai-service + tags: | + type=raw,${{ github.event.inputs.version }} + type=raw,latest + - name: Build and push + uses: docker/build-push-action@v6 + with: + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + context: ./wren-ai-service + file: ./wren-ai-service/docker/Dockerfile \ No newline at end of file diff --git a/.github/workflows/ai-service-ci.yaml b/.github/workflows/ai-service-test.yaml similarity index 73% rename from .github/workflows/ai-service-ci.yaml rename to .github/workflows/ai-service-test.yaml index 9023137c9..fbb933e63 100644 --- a/.github/workflows/ai-service-ci.yaml +++ b/.github/workflows/ai-service-test.yaml @@ -1,14 +1,16 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: AI Service CI +name: AI Service Test on: push: + branches: + - main paths: - - 'wren-ai-service/**' + - "wren-ai-service/**" pull_request: - types: [ labeled ] + types: [synchronize, labeled] permissions: contents: read @@ -23,25 +25,21 @@ defaults: working-directory: wren-ai-service jobs: - ci: - if: ${{ github.event.label.name == 'ci/ai-service' || github.event_name == 'push' }} - strategy: - fail-fast: false - matrix: - python-version: [ "3.12.0" ] - poetry-version: [ "1.8.3" ] + pytest: + if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/ai-service') || github.event_name == 'push' }} runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12.0 - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - name: Install Poetry - uses: abatilo/actions-poetry@v2 + uses: abatilo/actions-poetry@v3 + with: + poetry-version: "1.8.3" + - name: Set up Python + uses: actions/setup-python@v5 with: - poetry-version: ${{ matrix.poetry-version }} + python-version-file: ./wren-ai-service/pyproject.toml + cache: "poetry" - name: Install the project dependencies run: poetry install - name: Prepare testing environment and Run tests