Skip to content

bump version to 2.0.0 #7

bump version to 2.0.0

bump version to 2.0.0 #7

# https://gist.github.com/rexzhang/47a5b0e7baa8101bbfdef50c990e5337
name: Publish Docker Image to Docker Hub and GHCR
on:
push:
tags:
- "v*"
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ vars.DOCKERHUB_REPOSITORY }}
GHCR_IMAGE=ghcr.io/${{ github.repository }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION},${GHCR_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\.[0-9]{1,3})?$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest,${GHCR_IMAGE}:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@v5
- name: Install Cosign
# https://github.com/sigstore/cosign-installer
uses: sigstore/cosign-installer@v4.0.0
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up QEMU
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Docker Buildx
# https://github.com/docker/setup-buildx-action
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
# https://github.com/docker/login-action
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
# https://github.com/docker/build-push-action
id: docker_build
uses: docker/build-push-action@v6
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}