diff --git a/.gitignore b/.gitignore index a4ad067c..204e2cec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bin .tmp +release-out \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 5a50c1e6..6b1e6431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ dist: trusty sudo: required install: - - docker run --name buildkit --rm -d --privileged -p 1234:1234 tonistiigi/buildkit --addr tcp://0.0.0.0:1234 + - docker run --name buildkit --rm -d --privileged -p 1234:1234 $REPO_SLUG_ORIGIN --addr tcp://0.0.0.0:1234 - sudo docker cp buildkit:/usr/bin/buildctl /usr/bin/ - export BUILDKIT_HOST=tcp://0.0.0.0:1234 @@ -12,4 +12,30 @@ env: - PREFER_BUILDCTL="1" script: - - make binaries validate-all && ./hack/cross \ No newline at end of file + - make binaries validate-all && ./hack/cross + +before_deploy: + - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + +deploy: + - provider: script + script: ./hack/release master $REPO_SLUG_TARGET push + on: + repo: moby/buildkit + branch: master + - provider: script + script: ./hack/release $TRAVIS_TAG $REPO_SLUG_TARGET push && PLATFORMS="${PLATFORMS},darwin/amd64,windows/amd64" ./hack/release-tar $TRAVIS_TAG release-out + on: + repo: moby/buildkit + tags: true + condition: $TRAVIS_TAG =~ ^v[0-9] + - provider: releases + api_key: + secure: "hA0L2F6O1MLEJEbUDzxokpO6F6QrAIkltmVG3g0tTAoVj1xtCOXSmH3cAnVbFYyOz9q8pa/85tbpyEEIHVlqvWk2a5/QS16QaBW6XxH+FiZ3oQ44JbtpsjpmBFxdhfeFs8Ca6Nj29AOtDx21HHWsZKlBZFvC4Ubc05AM1rgZpJyZVDvYsjZIunc8/CPCbvAAp6RLnLHxAYXF+TQ7mAZP2SewsW/61nPjPIp2P4d93CduA9kUSxtC/1ewmU2T9Ak2X1Nw2ecPTonGjO51xNa6Ebo1hsbsRt5Krd1IR5rSkgXqLrhQO+19J3sUrQr2p8su6hCTKXR5TQz9L5C9VG8T3yOLbA7/FKBndWgBCm7EB7SezhFkm91e3Phkd/Hi5PF4ZKUSKyOYORHpoeg7ggBXaQF5r0OolqvNjxe7EhE+zlUIqnk5eprVrXT8H1QDF0Jg7pfdqVV9AIZO6i+e+1wOVDaP6K6tiWGdkRFH0wahcucZ/8xVoa8JVNZKke2mMCuLGsNWcN4DeLhkxa6giw3tkqbnY+eTYcW/PyVFMAVsZ8rOjQu4u4mm82FYBI7UywWQJTReD1LO2ibxHk74nwtyauX7KsCPFh2CA27DKlsQ1/xkjaCpE6vduzKzPj2DSHp6tKjxn2edPWRI+/4JxLD6KUFX1f1KqD0pKy/qVsZhEPI=" + file: release-out/**/* + skip_cleanup: true + file_glob: true + on: + repo: moby/buildkit + tags: true + condition: $TRAVIS_TAG =~ ^v[0-9] \ No newline at end of file diff --git a/cmd/buildctl/main.go b/cmd/buildctl/main.go index 358ea619..5f1a6d93 100644 --- a/cmd/buildctl/main.go +++ b/cmd/buildctl/main.go @@ -28,6 +28,7 @@ func main() { app := cli.NewApp() app.Name = "buildctl" app.Usage = "build utility" + app.Version = version.Version defaultAddress := os.Getenv("BUILDKIT_HOST") if defaultAddress == "" { diff --git a/cmd/buildkitd/main.go b/cmd/buildkitd/main.go index 2f74ad94..d714a2a5 100644 --- a/cmd/buildkitd/main.go +++ b/cmd/buildkitd/main.go @@ -85,6 +85,7 @@ func main() { app := cli.NewApp() app.Name = "buildkitd" app.Usage = "build daemon" + app.Version = version.Version defaultConf, md := defaultConf() diff --git a/hack/dockerfiles/test.Dockerfile b/hack/dockerfiles/test.Dockerfile index 472406fb..10e71560 100644 --- a/hack/dockerfiles/test.Dockerfile +++ b/hack/dockerfiles/test.Dockerfile @@ -5,7 +5,7 @@ ARG CONTAINERD10_VERSION=v1.0.3 # available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only ARG BUILDKIT_TARGET=buildkitd ARG REGISTRY_VERSION=2.6 -ARG ROOTLESSKIT_VERSION=d843aadf00d72082fd7a31572ef018d1e792535f +ARG ROOTLESSKIT_VERSION=4f7ae4607d626f0a22fb495056d55b17cce8c01b # The `buildkitd` stage and the `buildctl` stage are placed here # so that they can be built quickly with legacy DAG-unaware `docker build --target=...` diff --git a/hack/dockerfiles/test.buildkit.Dockerfile b/hack/dockerfiles/test.buildkit.Dockerfile index 9329f895..9a21a471 100644 --- a/hack/dockerfiles/test.buildkit.Dockerfile +++ b/hack/dockerfiles/test.buildkit.Dockerfile @@ -7,7 +7,7 @@ ARG CONTAINERD10_VERSION=v1.0.3 # available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only ARG BUILDKIT_TARGET=buildkitd ARG REGISTRY_VERSION=2.6 -ARG ROOTLESSKIT_VERSION=d843aadf00d72082fd7a31572ef018d1e792535f +ARG ROOTLESSKIT_VERSION=4f7ae4607d626f0a22fb495056d55b17cce8c01b ARG ROOTLESS_BASE_MODE=external # git stage is used for checking out remote repository sources @@ -70,8 +70,8 @@ WORKDIR /go/src/github.com/moby/buildkit # scan the version/revision info FROM buildkit-base AS buildkit-version -RUN --mount=target=.git,src=.git \ - PKG=github.com/moby/buildkit VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \ +RUN --mount=target=. \ + PKG=github.com/moby/buildkit VERSION=$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags) REVISION=$(git rev-parse HEAD)$(if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi); \ echo "-X ${PKG}/version.Version=${VERSION} -X ${PKG}/version.Revision=${REVISION} -X ${PKG}/version.Package=${PKG}" | tee /tmp/.ldflags; \ echo -n "${VERSION}" | tee /tmp/.version; @@ -204,14 +204,14 @@ COPY --from=binaries / /usr/bin/ COPY . . FROM alpine AS rootless-base-internal -RUN apk add --no-cache shadow shadow-uidmap \ +RUN apk add --no-cache git shadow shadow-uidmap \ && useradd --create-home --home-dir /home/user --uid 1000 user \ && mkdir -p /run/user/1000 /home/user/.local/tmp /home/user/.local/share/buildkit \ && chown -R user /run/user/1000 /home/user \ && rm /bin/su && ln -s /bin/busybox /bin/su # tonistiigi/buildkit:rootless-base is a pre-built multi-arch version of rootless-base-internal https://github.com/moby/buildkit/pull/666#pullrequestreview-161872350 -FROM tonistiigi/buildkit:rootless-base@sha256:a4999bc477416206973f93046ccfd9d82019f25bbc6400213bb2d27253e13c59 AS rootless-base-external +FROM tonistiigi/buildkit:rootless-base@sha256:6d9c50e2d006c2a8745e9d7f2bc075e4469191eccada41936ec0c6070361d45a AS rootless-base-external FROM rootless-base-$ROOTLESS_BASE_MODE AS rootless-base # Rootless mode. diff --git a/hack/release b/hack/release new file mode 100755 index 00000000..726b81b4 --- /dev/null +++ b/hack/release @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +TAG=$1 +REPO=$2 +PUSH=$3 + +set -eu -o pipefail + +: ${PLATFORMS=linux/amd64} +: ${CONTINUOUS_INTEGRATION=} + +progressFlag="" +if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi + + +usage() { + echo "usage: ./hack/release [push]" + exit 1 +} + +if [ -z "$TAG" ] || [ -z "$REPO" ]; then + usage +fi + +pushFlag="" +if [ "$PUSH" = "push" ]; then + pushFlag="--exporter-opt push=true" +fi + +tagLatest="" +tagLatestRootless="" +if [[ "$(git describe --tags --match "v[0-9]*")" == "$TAG" ]]; then + tagLatest=",$REPO:latest" + tagLatestRootless=",$REPO:rootless" +fi + +set -x + +buildctl build $progressFlag --frontend=dockerfile.v0 \ + --local context=. --local dockerfile=. \ + --frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \ + --frontend-opt platform=$PLATFORMS \ + --exporter image \ + --exporter-opt name=$REPO:$TAG$tagLatest $pushFlag + +buildctl build $progressFlag --frontend=dockerfile.v0 \ + --local context=. --local dockerfile=. \ + --frontend-opt target=rootless \ + --frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \ + --frontend-opt platform=$PLATFORMS \ + --exporter image \ + --exporter-opt name=$REPO:$TAG-rootless$tagLatestRootless $pushFlag \ No newline at end of file diff --git a/hack/release-tar b/hack/release-tar new file mode 100755 index 00000000..e93ea803 --- /dev/null +++ b/hack/release-tar @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +TAG=$1 +OUT=$2 + +set -eu -o pipefail + +: ${PLATFORMS=linux/amd64} +: ${CONTINUOUS_INTEGRATION=} + +progressFlag="" +if [ "$CONTINUOUS_INTEGRATION" == "true" ]; then progressFlag="--progress=plain"; fi + + +usage() { + echo "usage: ./hack/release-tar " + exit 1 +} + +if [ -z "$TAG" ] || [ -z "$OUT" ]; then + usage +fi + + +set -x + +buildctl build $progressFlag --frontend=dockerfile.v0 \ + --local context=. --local dockerfile=. \ + --frontend-opt filename=./hack/dockerfiles/test.buildkit.Dockerfile \ + --frontend-opt target=release \ + --frontend-opt platform=$PLATFORMS \ + --exporter local \ + --exporter-opt output=$OUT