fix: lfs #3
Workflow file for this run
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 | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| jobs: | |
| build-and-push: | |
| name: Build And Push | |
| runs-on: ubuntu-latest | |
| needs: [] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| lfs: true | |
| - name: Get version | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/* ]]; then | |
| CURRENT_VERSION=${GITHUB_REF#refs/tags/} | |
| echo "Triggered by tag: $CURRENT_VERSION" | |
| echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "Triggered by branch push, calculating new version..." | |
| LATEST_TAG=$(git tag -l "v*.*.*" | sort -V | tail -n1) | |
| if [ -z "$LATEST_TAG" ]; then | |
| # If no tag, start from v1.0.0 | |
| NEW_VERSION="v1.0.0" | |
| else | |
| echo "Latest tag: $LATEST_TAG" | |
| VERSION_PART=$(echo $LATEST_TAG | sed 's/v//') | |
| MAJOR=$(echo $VERSION_PART | cut -d. -f1) | |
| MINOR=$(echo $VERSION_PART | cut -d. -f2) | |
| PATCH=$(echo $VERSION_PART | cut -d. -f3) | |
| PATCH=$((PATCH + 1)) | |
| NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}" | |
| fi | |
| echo "New version: $NEW_VERSION" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v2 | |
| with: | |
| version: latest | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v1 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Push to Docker Hub | |
| uses: docker/build-push-action@v3 | |
| with: | |
| context: . | |
| target: runtime | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_REPOSITORY }}/code-completion:${{ steps.version.outputs.version }},${{ secrets.DOCKERHUB_REPOSITORY }}/code-completion:latest | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} # GitHub 自动提供 | |
| - name: Build and push image to ghcr | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:latest | |
| ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} |