ci: use repo token for homebrew tap in release workflow #13
Workflow file for this run
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: Docker | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-image: | |
| strategy: | |
| matrix: | |
| include: | |
| - architecture: x86_64 | |
| runner: ubuntu-24.04 | |
| - architecture: aarch64 | |
| runner: ubuntu-24.04-arm | |
| fail-fast: false | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - name: Setup docker arch | |
| id: setup-docker-arch | |
| env: | |
| ARCHITECTURE: ${{ matrix.architecture }} | |
| run: | | |
| case "${ARCHITECTURE}" in | |
| x86_64) | |
| DOCKER_ARCH="amd64" | |
| ;; | |
| aarch64) | |
| DOCKER_ARCH="arm64" | |
| ;; | |
| *) | |
| echo "Unsupported architecture: $ARCHITECTURE}" | |
| exit 1 | |
| ;; | |
| esac | |
| echo "DOCKER_ARCH=$DOCKER_ARCH" >> $GITHUB_OUTPUT | |
| echo "Docker architecture: $DOCKER_ARCH" | |
| shell: bash | |
| - uses: actions/checkout@v6 | |
| name: Checkout code | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build Docker image | |
| run: | | |
| docker buildx build --platform linux/${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }} --output type=docker -t ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }} . | |
| shell: bash | |
| - name: Save Docker image as artifact | |
| run: | | |
| docker save ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }} -o image-${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }}.tar | |
| shell: bash | |
| - name: Upload image artifact | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: image-${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }} | |
| path: image-${{ steps.setup-docker-arch.outputs.DOCKER_ARCH }}.tar | |
| push-manifest: | |
| needs: build-image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download amd64 image | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: image-amd64 | |
| path: ./amd64 | |
| - name: Download arm64 image | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: image-arm64 | |
| path: ./arm64 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Load images | |
| run: | | |
| docker load -i ./amd64/image-amd64.tar | |
| docker load -i ./arm64/image-arm64.tar | |
| shell: bash | |
| - name: Push images (no manifest) | |
| run: | | |
| docker push ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-amd64 | |
| docker push ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-arm64 | |
| shell: bash | |
| - name: Extract metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/riptideslabs/keyledger | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | |
| type=edge,branch=main | |
| - name: Create and push multi-arch manifest | |
| env: | |
| TAGS: ${{ steps.meta.outputs.tags }} | |
| LABELS: ${{ steps.meta.outputs.labels }} | |
| run: | | |
| mapfile -t TAGS_ARRAY <<< "$TAGS" | |
| TAG_ARGS=() | |
| for tag in "${TAGS_ARRAY[@]}"; do | |
| [[ -n "$tag" ]] && TAG_ARGS+=("-t" "$tag") | |
| done | |
| mapfile -t LABELS_ARRAY <<< "$LABELS" | |
| ANNOTATION_ARGS=() | |
| for label in "${LABELS_ARRAY[@]}"; do | |
| [[ -n "$label" ]] && ANNOTATION_ARGS+=("--annotation" "index:$label") | |
| done | |
| docker buildx imagetools create \ | |
| "${TAG_ARGS[@]}" \ | |
| "${ANNOTATION_ARGS[@]}" \ | |
| ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-amd64 \ | |
| ghcr.io/riptideslabs/${{ github.event.repository.name }}:${{ github.ref_name }}-arm64 | |
| shell: bash |