Drop qemu #17
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: Build Cupcake | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags-ignore: | |
| - '**' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| meta: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| short_sha_tag: ${{ steps.short_sha.outputs.short_sha_tag }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - id: short_sha | |
| name: Compute short-sha tag | |
| run: echo "short_sha_tag=sha-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | |
| - id: meta | |
| name: Docker metadata | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ghcr.io/javabin/cupcake | |
| tags: | | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=sha,format=short | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '22' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v6 | |
| - name: Test | |
| run: ./gradlew clean check | |
| - name: Upload reports if failed | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: reports | |
| path: | | |
| **/build/reports/ | |
| **/build/test-results/ | |
| - name: Upload coverage if passed | |
| if: success() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage | |
| path: | | |
| **/build/reports/jacoco/ | |
| build-amd64: | |
| runs-on: ubuntu-latest | |
| needs: [meta, test] | |
| env: | |
| IMAGE_BASE: ghcr.io/javabin/cupcake | |
| SHORT_SHA_TAG: ${{ needs.meta.outputs.short_sha_tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build and push (amd64) | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ env.IMAGE_BASE }}:${{ env.SHORT_SHA_TAG }}-amd64 | |
| cache-from: type=gha,scope=amd64 | |
| cache-to: type=gha,mode=max,scope=amd64 | |
| build-arm64: | |
| runs-on: ubuntu-24.04-arm | |
| needs: [meta, test] | |
| env: | |
| IMAGE_BASE: ghcr.io/javabin/cupcake | |
| SHORT_SHA_TAG: ${{ needs.meta.outputs.short_sha_tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Build and push (arm64) | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| platforms: linux/arm64 | |
| push: true | |
| tags: ${{ env.IMAGE_BASE }}:${{ env.SHORT_SHA_TAG }}-arm64 | |
| cache-from: type=gha,scope=arm64 | |
| cache-to: type=gha,mode=max,scope=arm64 | |
| manifest: | |
| runs-on: ubuntu-latest | |
| needs: [meta, build-amd64, build-arm64] | |
| env: | |
| IMAGE_BASE: ghcr.io/javabin/cupcake | |
| SHORT_SHA_TAG: ${{ needs.meta.outputs.short_sha_tag }} | |
| TAGS: ${{ needs.meta.outputs.tags }} | |
| LABELS: ${{ needs.meta.outputs.labels }} | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Login to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Create multi-arch manifests for all tags | |
| run: | | |
| while IFS= read -r tag; do | |
| [ -z "$tag" ] && continue | |
| docker buildx imagetools create \ | |
| -t "$tag" \ | |
| "${IMAGE_BASE}:${SHORT_SHA_TAG}-amd64" \ | |
| "${IMAGE_BASE}:${SHORT_SHA_TAG}-arm64" | |
| done <<< "${TAGS}" | |
| - name: Create staging | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag "${IMAGE_BASE}:staging" \ | |
| "${IMAGE_BASE}:latest" | |
| - name: Generate summary | |
| run: | | |
| echo "Short SHA Tag: ${SHORT_SHA_TAG}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Image base: ${IMAGE_BASE}" >> "$GITHUB_STEP_SUMMARY" |