|
| 1 | +# Build and publish multi-arch Docker image to GHCR. |
| 2 | +# |
| 3 | +# Triggered by repository_dispatch from the blumo release workflow |
| 4 | +# after a new CLI release is published. Downloads the pre-built Linux |
| 5 | +# binaries from the release and builds the Docker image. |
| 6 | + |
| 7 | +name: Docker Image |
| 8 | + |
| 9 | +on: |
| 10 | + repository_dispatch: |
| 11 | + types: [release-published] |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + docker: |
| 19 | + name: Build and push Docker image |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Get version from event |
| 23 | + id: version |
| 24 | + run: | |
| 25 | + VERSION="${{ github.event.client_payload.version }}" |
| 26 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 27 | + echo "Building Docker image for version: $VERSION" |
| 28 | +
|
| 29 | + - name: Checkout (for Dockerfile) |
| 30 | + uses: actions/checkout@v6 |
| 31 | + |
| 32 | + - name: Download release binaries |
| 33 | + env: |
| 34 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 35 | + run: | |
| 36 | + VERSION="${{ steps.version.outputs.version }}" |
| 37 | + mkdir -p build/amd64 build/arm64 |
| 38 | +
|
| 39 | + # Download and extract linux/amd64 |
| 40 | + gh release download "$VERSION" --pattern "paperhero_linux_amd64.tar.gz" --dir /tmp |
| 41 | + tar -xzf /tmp/paperhero_linux_amd64.tar.gz -C build/amd64/ |
| 42 | +
|
| 43 | + # Download and extract linux/arm64 |
| 44 | + gh release download "$VERSION" --pattern "paperhero_linux_arm64.tar.gz" --dir /tmp |
| 45 | + tar -xzf /tmp/paperhero_linux_arm64.tar.gz -C build/arm64/ |
| 46 | +
|
| 47 | + # Copy Dockerfile into each context |
| 48 | + cp Dockerfile build/amd64/ |
| 49 | + cp Dockerfile build/arm64/ |
| 50 | +
|
| 51 | + - name: Set up Docker Buildx |
| 52 | + uses: docker/setup-buildx-action@v3 |
| 53 | + |
| 54 | + - name: Log in to GHCR |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Build and push amd64 |
| 62 | + uses: docker/build-push-action@v6 |
| 63 | + with: |
| 64 | + context: build/amd64 |
| 65 | + platforms: linux/amd64 |
| 66 | + push: true |
| 67 | + tags: ghcr.io/blaumedia/paperhero-cli:${{ steps.version.outputs.version }}-amd64 |
| 68 | + labels: | |
| 69 | + org.opencontainers.image.source=https://github.com/blaumedia/paperhero-cli |
| 70 | + org.opencontainers.image.description=PaperHero CLI - Document management for humans and AI agents |
| 71 | + org.opencontainers.image.licenses=MIT |
| 72 | + provenance: false |
| 73 | + |
| 74 | + - name: Build and push arm64 |
| 75 | + uses: docker/build-push-action@v6 |
| 76 | + with: |
| 77 | + context: build/arm64 |
| 78 | + platforms: linux/arm64 |
| 79 | + push: true |
| 80 | + tags: ghcr.io/blaumedia/paperhero-cli:${{ steps.version.outputs.version }}-arm64 |
| 81 | + labels: | |
| 82 | + org.opencontainers.image.source=https://github.com/blaumedia/paperhero-cli |
| 83 | + org.opencontainers.image.description=PaperHero CLI - Document management for humans and AI agents |
| 84 | + org.opencontainers.image.licenses=MIT |
| 85 | + provenance: false |
| 86 | + |
| 87 | + - name: Create and push multi-arch manifest |
| 88 | + env: |
| 89 | + VERSION: ${{ steps.version.outputs.version }} |
| 90 | + run: | |
| 91 | + docker manifest create ghcr.io/blaumedia/paperhero-cli:${VERSION} \ |
| 92 | + ghcr.io/blaumedia/paperhero-cli:${VERSION}-amd64 \ |
| 93 | + ghcr.io/blaumedia/paperhero-cli:${VERSION}-arm64 |
| 94 | + docker manifest push ghcr.io/blaumedia/paperhero-cli:${VERSION} |
| 95 | +
|
| 96 | + docker manifest create --amend ghcr.io/blaumedia/paperhero-cli:latest \ |
| 97 | + ghcr.io/blaumedia/paperhero-cli:${VERSION}-amd64 \ |
| 98 | + ghcr.io/blaumedia/paperhero-cli:${VERSION}-arm64 |
| 99 | + docker manifest push ghcr.io/blaumedia/paperhero-cli:latest |
| 100 | +
|
| 101 | + echo "Published:" |
| 102 | + echo " ghcr.io/blaumedia/paperhero-cli:${VERSION}" |
| 103 | + echo " ghcr.io/blaumedia/paperhero-cli:latest" |
0 commit comments