diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..dec3f62 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,64 @@ +name: Docker release + +# Builds and publishes a multi-arch (linux/amd64 + linux/arm64) Docker +# image whenever a version tag (e.g. "v1.2.3") is pushed, or a release is +# published for one. Written against the GitHub Actions syntax, which +# Gitea Actions runs unmodified — the ${{ github.* }} context and +# secrets.GITHUB_TOKEN are provided as compatibility aliases by Gitea's +# act runner, so this workflow works as-is on either platform. +# +# The image is pushed to this server's own container registry, addressed +# as "//" (e.g. git.example.com/owner/nidus on Gitea, +# or ghcr.io/owner/nidus if this repo is ever mirrored to GitHub). + +on: + push: + tags: + - "v*" + release: + types: [published] + +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Determine registry, image name, and tags + id: vars + run: | + registry="$(echo "${{ github.server_url }}" | sed -E 's#^https?://##')" + image_name="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')" + image="${registry}/${image_name}" + version="${GITHUB_REF_NAME#v}" + + { + echo "registry=${registry}" + echo "image=${image}" + echo "tags=${image}:${version},${image}:latest" + } >> "$GITHUB_OUTPUT" + + - 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 the container registry + uses: docker/login-action@v3 + with: + registry: ${{ steps.vars.outputs.registry }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.vars.outputs.tags }}