mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 10:03:42 +08:00 
			
		
		
		
	GitHub Actions cross
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										34
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										34
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -14,6 +14,7 @@ on:
 | 
				
			|||||||
env:
 | 
					env:
 | 
				
			||||||
  REPO_SLUG_ORIGIN: "moby/buildkit:master"
 | 
					  REPO_SLUG_ORIGIN: "moby/buildkit:master"
 | 
				
			||||||
  CACHEKEY_BINARIES: "binaries"
 | 
					  CACHEKEY_BINARIES: "binaries"
 | 
				
			||||||
 | 
					  PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/s390x,linux/ppc64le"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
jobs:
 | 
					jobs:
 | 
				
			||||||
  base:
 | 
					  base:
 | 
				
			||||||
@@ -82,9 +83,40 @@ jobs:
 | 
				
			|||||||
        env:
 | 
					        env:
 | 
				
			||||||
          TEST_COVERAGE: 1
 | 
					          TEST_COVERAGE: 1
 | 
				
			||||||
          TESTFLAGS: -v --parallel=6 --timeout=20m
 | 
					          TESTFLAGS: -v --parallel=6 --timeout=20m
 | 
				
			||||||
          CACHEDIR_FROM: /tmp/.buildkit-cache/${{ env.CACHEKEY_BINARIES }}
 | 
					          CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
 | 
				
			||||||
      -
 | 
					      -
 | 
				
			||||||
        name: Send to Codecov
 | 
					        name: Send to Codecov
 | 
				
			||||||
        uses: codecov/codecov-action@v1
 | 
					        uses: codecov/codecov-action@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          file: ./coverage/coverage.txt
 | 
					          file: ./coverage/coverage.txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  cross:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    needs: [base]
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      -
 | 
				
			||||||
 | 
					        name: Checkout
 | 
				
			||||||
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
 | 
					      -
 | 
				
			||||||
 | 
					        name: Cache ${{ env.CACHEKEY_BINARIES }}
 | 
				
			||||||
 | 
					        uses: actions/cache@v2
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          path: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
 | 
				
			||||||
 | 
					          key: ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-${{ github.sha }}
 | 
				
			||||||
 | 
					          restore-keys: |
 | 
				
			||||||
 | 
					            ${{ runner.os }}-buildx-${{ env.CACHEKEY_BINARIES }}-
 | 
				
			||||||
 | 
					      -
 | 
				
			||||||
 | 
					        name: Set up QEMU
 | 
				
			||||||
 | 
					        uses: docker/setup-qemu-action@v1
 | 
				
			||||||
 | 
					      -
 | 
				
			||||||
 | 
					        name: Set up Docker Buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v1
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          driver-opts: image=${{ env.REPO_SLUG_ORIGIN }}
 | 
				
			||||||
 | 
					      -
 | 
				
			||||||
 | 
					        name: Cross
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          make cross
 | 
				
			||||||
 | 
					        env:
 | 
				
			||||||
 | 
					          TARGETPLATFORM: ${{ env.PLATFORMS }},darwin/amd64,windows/amd64
 | 
				
			||||||
 | 
					          CACHEDIR_FROM: /tmp/.buildx-cache/${{ env.CACHEKEY_BINARIES }}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										3
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								Makefile
									
									
									
									
									
								
							@@ -7,6 +7,9 @@ binaries:
 | 
				
			|||||||
binaries-cross:
 | 
					binaries-cross:
 | 
				
			||||||
	EXPORT_LOCAL=cross-out ./hack/cross
 | 
						EXPORT_LOCAL=cross-out ./hack/cross
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					cross:
 | 
				
			||||||
 | 
						./hack/cross
 | 
				
			||||||
 | 
					
 | 
				
			||||||
install: binaries
 | 
					install: binaries
 | 
				
			||||||
	mkdir -p ~/.docker/cli-plugins
 | 
						mkdir -p ~/.docker/cli-plugins
 | 
				
			||||||
	cp bin/buildx ~/.docker/cli-plugins/docker-buildx
 | 
						cp bin/buildx ~/.docker/cli-plugins/docker-buildx
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										20
									
								
								hack/cross
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								hack/cross
									
									
									
									
									
								
							@@ -1,20 +1,24 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
. $(dirname $0)/util
 | 
					. $(dirname $0)/util
 | 
				
			||||||
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: ${TARGETPLATFORM=linux/amd64,linux/arm/v7,linux/arm64,darwin/amd64,windows/amd64,linux/ppc64le,linux/s390x}
 | 
					: ${TARGETPLATFORM=linux/amd64,linux/arm/v7,linux/arm64,darwin/amd64,windows/amd64,linux/ppc64le,linux/s390x}
 | 
				
			||||||
: ${CONTINUOUS_INTEGRATION=}
 | 
					 | 
				
			||||||
: ${EXPORT_LOCAL=}
 | 
					: ${EXPORT_LOCAL=}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -ex
 | 
					importCacheFlags=""
 | 
				
			||||||
 | 
					if [ "$GITHUB_ACTIONS" = "true" ]; then
 | 
				
			||||||
 | 
					  if [ -n "$cacheRefFrom" ]; then
 | 
				
			||||||
 | 
					    importCacheFlags="--cache-from=type=local,src=$cacheRefFrom"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exportFlag=""
 | 
					exportFlag=""
 | 
				
			||||||
if [ -n "$EXPORT_LOCAL" ]; then
 | 
					if [ -n "$EXPORT_LOCAL" ]; then
 | 
				
			||||||
	exportFlag="--output=type=local,dest=$EXPORT_LOCAL"
 | 
					  exportFlag="--output=type=local,dest=$EXPORT_LOCAL"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
progressFlag=""
 | 
					buildxCmd build $importCacheFlags $exportFlag \
 | 
				
			||||||
if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain";
 | 
					  --target "binaries" \
 | 
				
			||||||
fi
 | 
					  --platform "$TARGETPLATFORM" \
 | 
				
			||||||
 | 
					  $currentcontext
 | 
				
			||||||
buildctl build $progressFlag --frontend=dockerfile.v0 --local context=. --local dockerfile=. --opt platform=$TARGETPLATFORM $exportFlag --opt target=binaries
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user