feat: update redis client #release #22
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
| # .github/workflows/ci.yml | |
| name: CI (Build & Push Docker + Auto Release) | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: [ "v*.*.*", "*.*.*" ] # supports v2.0.1 or 2.0.1 | |
| workflow_dispatch: {} | |
| env: | |
| REGISTRY: docker.io | |
| IMAGE_NAME: ${{ secrets.DOCKERHUB_USERNAME }}/gabs-redis-langcache | |
| DOCKERFILE: ./Dockerfile | |
| permissions: | |
| contents: write # needed to push tags & create releases | |
| jobs: | |
| build-and-push: | |
| name: Build & Push multi-arch image to Docker Hub | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| 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: 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 on tag events; latest/branch/sha on main pushes | |
| tags: | | |
| type=semver,pattern={{version}},enable=${{ github.ref_type == 'tag' }} | |
| type=raw,value=latest,enable=${{ github.ref_type == 'branch' && github.ref_name == 'main' }} | |
| type=ref,event=branch,enable=${{ github.ref_type == 'branch' }} | |
| type=sha,enable=${{ github.ref_type == 'branch' }} | |
| labels: | | |
| org.opencontainers.image.title=${{ github.event.repository.name }} | |
| org.opencontainers.image.source=${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Debug tags & labels | |
| run: | | |
| echo "TAGS:" | |
| echo "${{ steps.meta.outputs.tags }}" | |
| echo | |
| echo "LABELS:" | |
| echo "${{ steps.meta.outputs.labels }}" | |
| - name: Build & Push (linux/amd64 + linux/arm64) | |
| 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: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # need full history for tags | |
| - name: Bump patch version and create tag | |
| id: bump | |
| run: | | |
| set -e | |
| LAST=$(git tag -l 'v*' --sort=-v:refname | head -n1) | |
| if [ -z "$LAST" ]; then LAST="v0.0.0"; fi | |
| 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" | |
| echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.bump.outputs.tag }} | |
| name: Release ${{ steps.bump.outputs.tag }} | |
| body: | | |
| 🚀 Automated release from CI. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |