feat: new cache engine #release #24
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: CI (Build & Push Docker + Auto Release) | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ "v*.*.*", "*.*.*" ] | |
| workflow_dispatch: {} | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/gabs-redis-langcache | |
| DOCKERFILE: ./Dockerfile | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Sanitize Docker context env | |
| run: echo "DOCKER_CONTEXT=" >> $GITHUB_ENV | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| # 👉 Only semver tags when triggered by a tag event | |
| tags: | | |
| type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }} | |
| type=raw,value=latest,enable=${{ github.ref_name == 'main' && !startsWith(github.ref, 'refs/tags/') }} | |
| type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/tags/') }} | |
| type=sha,enable=${{ !startsWith(github.ref, 'refs/tags/') }} | |
| labels: | | |
| org.opencontainers.image.title=${{ github.event.repository.name }} | |
| org.opencontainers.image.source=${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Debug tags | |
| run: echo "→ ${{ steps.meta.outputs.tags }}" | |
| - name: Build & Push multi-arch | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE }} | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| provenance: false | |
| auto-release: | |
| needs: build-and-push | |
| if: contains(github.event.head_commit.message, '#release') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Bump patch version and create tag | |
| id: bump | |
| run: | | |
| set -e | |
| LAST=$(git tag -l 'v*' --sort=-v:refname | head -n1) | |
| [ -z "$LAST" ] && LAST="v0.0.0" | |
| VER=${LAST#v} | |
| IFS='.' read -r MA MI PA <<<"$VER" | |
| NEW_TAG="v$MA.$MI.$((PA+1))" | |
| echo "New tag: $NEW_TAG" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$NEW_TAG" -m "release $NEW_TAG" | |
| git push origin "$NEW_TAG" |