chore: 批量更新所有项目版本至 0.7.0 #110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Push AI | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| tags: [ "v*.*.*" ] | |
| paths: | |
| - 'package/ai/**' | |
| - '.github/workflows/docker-build-push-ai.yml' | |
| jobs: | |
| build-and-push-ai: | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '构建ai' ) || contains(github.event.head_commit.message, '构建AI') | |
| strategy: | |
| matrix: | |
| include: | |
| - type: cpu | |
| dockerfile: Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| tag_suffix: "-cpu" | |
| - type: gpu | |
| dockerfile: Dockerfile.gpu | |
| platforms: linux/amd64 | |
| tag_suffix: "-gpu" | |
| - type: openvino | |
| dockerfile: Dockerfile.openvino | |
| platforms: linux/amd64 | |
| tag_suffix: "-openvino" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| install: true | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Determine image tags | |
| id: set-tags | |
| env: | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| RAW_BASE_TAG=${GITHUB_REF#refs/tags/v} | |
| RAW_EXTRA_TAGS="latest" | |
| else | |
| RAW_BASE_TAG=${GITHUB_REF#refs/heads/} | |
| RAW_EXTRA_TAGS="" | |
| fi | |
| if [[ "$COMMIT_MSG" == *"-latest"* ]]; then | |
| RAW_EXTRA_TAGS="latest" | |
| fi | |
| # Append suffix from matrix | |
| BASE_TAG="${RAW_BASE_TAG}${{ matrix.tag_suffix }}" | |
| if [ -n "$RAW_EXTRA_TAGS" ]; then | |
| EXTRA_TAGS="${RAW_EXTRA_TAGS}${{ matrix.tag_suffix }}" | |
| else | |
| EXTRA_TAGS="" | |
| fi | |
| echo "BASE_TAG=$BASE_TAG" >> $GITHUB_ENV | |
| echo "EXTRA_TAGS=$EXTRA_TAGS" >> $GITHUB_ENV | |
| echo "RAW_BASE_TAG=$RAW_BASE_TAG" >> $GITHUB_ENV | |
| echo "RAW_EXTRA_TAGS=$RAW_EXTRA_TAGS" >> $GITHUB_ENV | |
| echo "DOCKER_HUB_USERNAME=${{ secrets.DOCKER_HUB_USERNAME }}" >> $GITHUB_ENV | |
| - name: Build and push ai | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./package/ai | |
| file: ./package/ai/${{ matrix.dockerfile }} | |
| platforms: ${{ matrix.platforms }} | |
| push: true | |
| tags: | | |
| ${{ env.DOCKER_HUB_USERNAME }}/trailsnap-ai:${{ env.BASE_TAG }} | |
| ${{ env.EXTRA_TAGS != '' && format('{0}/trailsnap-ai:{1}', env.DOCKER_HUB_USERNAME, env.EXTRA_TAGS) || '' }} | |
| ${{ matrix.type == 'cpu' && format('{0}/trailsnap-ai:{1}', env.DOCKER_HUB_USERNAME, env.RAW_BASE_TAG) || '' }} | |
| ${{ matrix.type == 'cpu' && env.RAW_EXTRA_TAGS != '' && format('{0}/trailsnap-ai:{1}', env.DOCKER_HUB_USERNAME, env.RAW_EXTRA_TAGS) || '' }} | |
| cache-from: type=gha,scope=build-ai-${{ matrix.type }} | |
| cache-to: type=gha,mode=max,scope=build-ai-${{ matrix.type }} |