This repository was archived by the owner on Mar 18, 2026. It is now read-only.
fix(goreleaser): update image owner in templates for Docker images (#15) #63
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: GO | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "*" ] | |
| jobs: | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Set up Go 1.x | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: 1.23.x | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@v4 | |
| - name: Install Dependencies | |
| run: | | |
| sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu \ | |
| libbtrfs-dev libgpgme-dev libdevmapper-dev \ | |
| qemu-user-static binfmt-support | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| args: build --snapshot --clean --timeout=1h | |
| - name: Copy file | |
| run: | | |
| cp dist/sreg_linux_amd64*/sreg sreg | |
| chmod a+x sreg | |
| ./sreg version | |
| - name: Upload linux-amd64 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sreg-linux-amd64 | |
| path: dist/sreg_linux_amd64*/sreg | |
| - name: Upload linux-arm64 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sreg-linux-arm64 | |
| path: dist/sreg_linux_arm64*/sreg | |
| - name: Resolve image owner | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| id: owner | |
| run: echo "value=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" | |
| - name: Set up Docker Buildx | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push main Docker images | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| set -euo pipefail | |
| OWNER="${{ steps.owner.outputs.value }}" | |
| SHORT_SHA="${GITHUB_SHA::7}" | |
| AMD64_BIN="$(find dist -type f -path '*/sreg_linux_amd64*/sreg' | head -n 1)" | |
| ARM64_BIN="$(find dist -type f -path '*/sreg_linux_arm64*/sreg' | head -n 1)" | |
| if [ -z "${AMD64_BIN}" ] || [ -z "${ARM64_BIN}" ]; then | |
| echo "failed to locate linux binaries in dist/" | |
| exit 1 | |
| fi | |
| build_and_push() { | |
| local image="$1" | |
| local dockerfile="$2" | |
| local binary="$3" | |
| local arch="$4" | |
| cp "${binary}" sreg | |
| chmod +x sreg | |
| docker buildx build \ | |
| --platform "linux/${arch}" \ | |
| -f "${dockerfile}" \ | |
| -t "ghcr.io/${OWNER}/${image}:main-${arch}" \ | |
| -t "ghcr.io/${OWNER}/${image}:sha-${SHORT_SHA}-${arch}" \ | |
| --push . | |
| } | |
| build_and_push "sreg" "Dockerfile" "${AMD64_BIN}" "amd64" | |
| build_and_push "sreg" "Dockerfile" "${ARM64_BIN}" "arm64" | |
| build_and_push "sreg-storage" "Dockerfile.sreg-storage" "${AMD64_BIN}" "amd64" | |
| build_and_push "sreg-storage" "Dockerfile.sreg-storage" "${ARM64_BIN}" "arm64" | |
| docker buildx imagetools create \ | |
| -t "ghcr.io/${OWNER}/sreg:main" \ | |
| -t "ghcr.io/${OWNER}/sreg:sha-${SHORT_SHA}" \ | |
| "ghcr.io/${OWNER}/sreg:main-amd64" \ | |
| "ghcr.io/${OWNER}/sreg:main-arm64" | |
| docker buildx imagetools create \ | |
| -t "ghcr.io/${OWNER}/sreg-storage:main" \ | |
| -t "ghcr.io/${OWNER}/sreg-storage:sha-${SHORT_SHA}" \ | |
| "ghcr.io/${OWNER}/sreg-storage:main-amd64" \ | |
| "ghcr.io/${OWNER}/sreg-storage:main-arm64" |