From 86b36fa8691a49a7083bc2cf7064a3cae70d5edc Mon Sep 17 00:00:00 2001 From: Prashant Srivastava Date: Fri, 16 Apr 2021 12:04:37 -0700 Subject: [PATCH 1/4] Adding separate workflow for dockerhub --- .github/workflows/release-build-publish.yml | 6 +- .../workflows/release-publish-Dockerhub.yml | 61 +++++++++++++++++++ .github/workflows/release-publish-ECR.yml | 0 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-publish-Dockerhub.yml create mode 100644 .github/workflows/release-publish-ECR.yml diff --git a/.github/workflows/release-build-publish.yml b/.github/workflows/release-build-publish.yml index 83be000..9bbead7 100644 --- a/.github/workflows/release-build-publish.yml +++ b/.github/workflows/release-build-publish.yml @@ -5,6 +5,9 @@ on: version: description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 required: true + major_version: + description: The major version to tag the release with, e.g., 1.x, 2.x, 3.x + required: true jobs: build_publish_daemon_image: @@ -101,9 +104,10 @@ jobs: tags: | amazon/aws-xray-daemon:${{ github.event.inputs.version }} amazon/aws-xray-daemon:latest - amazon/aws-xray-daemon:3.x + amazon/aws-xray-daemon:${{ github.event.inputs.major_version }} public.ecr.aws/xray/aws-xray-daemon:${{ github.event.inputs.version }} public.ecr.aws/xray/aws-xray-daemon:latest + public.ecr.aws/xray/aws-xray-daemon:${{ github.event.inputs.major_version }} push: true cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/release-publish-Dockerhub.yml b/.github/workflows/release-publish-Dockerhub.yml new file mode 100644 index 0000000..fa24c6c --- /dev/null +++ b/.github/workflows/release-publish-Dockerhub.yml @@ -0,0 +1,61 @@ +name: Build and release DockerHub image +on: + workflow_dispatch: + inputs: + version: + description: The complete version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1 + required: true + major_version: + description: The major version to tag the release with, e.g., 2.x, 3.x + required: true + +jobs: + build_publish_DockerHub_image: + name: Build X-Ray daemon docker image with amazonlinux base & release to DockerHub + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: '^1.16' + + - uses: actions/cache@v2 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Build docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile.amazonlinux + platforms: linux/amd64,linux/arm64 + tags: | + amazon/aws-xray-daemon:${{ github.event.inputs.version }} + amazon/aws-xray-daemon:latest + amazon/aws-xray-daemon:${{ github.event.inputs.major_version }} + push: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file diff --git a/.github/workflows/release-publish-ECR.yml b/.github/workflows/release-publish-ECR.yml new file mode 100644 index 0000000..e69de29 From 2cc2a717d5c02f731f8f310160f65d57fc0ec8de Mon Sep 17 00:00:00 2001 From: Prashant Srivastava Date: Fri, 16 Apr 2021 13:21:22 -0700 Subject: [PATCH 2/4] adding build step --- .github/workflows/release-publish-Dockerhub.yml | 7 ++++++- .github/workflows/release-publish-ECR.yml | 0 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 .github/workflows/release-publish-ECR.yml diff --git a/.github/workflows/release-publish-Dockerhub.yml b/.github/workflows/release-publish-Dockerhub.yml index fa24c6c..8d1a91f 100644 --- a/.github/workflows/release-publish-Dockerhub.yml +++ b/.github/workflows/release-publish-Dockerhub.yml @@ -29,6 +29,11 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Build and test + run: make build test + env: + VERSION: ${{ github.event.inputs.version }} + - name: Login to DockerHub uses: docker/login-action@v1 with: @@ -58,4 +63,4 @@ jobs: amazon/aws-xray-daemon:${{ github.event.inputs.major_version }} push: true cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file + cache-to: type=local,dest=/tmp/.buildx-cache diff --git a/.github/workflows/release-publish-ECR.yml b/.github/workflows/release-publish-ECR.yml deleted file mode 100644 index e69de29..0000000 From f4d72be61b2503839a96d36662e67e1087f5abb1 Mon Sep 17 00:00:00 2001 From: Prashant Srivastava Date: Fri, 16 Apr 2021 14:00:06 -0700 Subject: [PATCH 3/4] Splitting ECR and DockerHub images step --- .github/workflows/release-build-publish.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-build-publish.yml b/.github/workflows/release-build-publish.yml index 9bbead7..46f76e1 100644 --- a/.github/workflows/release-build-publish.yml +++ b/.github/workflows/release-build-publish.yml @@ -96,15 +96,13 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Build docker image + - name: Build docker image for Public ECR uses: docker/build-push-action@v2 with: context: . + file: ./Dockerfile platforms: linux/amd64,linux/arm64 tags: | - amazon/aws-xray-daemon:${{ github.event.inputs.version }} - amazon/aws-xray-daemon:latest - amazon/aws-xray-daemon:${{ github.event.inputs.major_version }} public.ecr.aws/xray/aws-xray-daemon:${{ github.event.inputs.version }} public.ecr.aws/xray/aws-xray-daemon:latest public.ecr.aws/xray/aws-xray-daemon:${{ github.event.inputs.major_version }} @@ -112,6 +110,20 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + - name: Build docker image for DockerHub + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile.amazonlinux + platforms: linux/amd64,linux/arm64 + tags: | + amazon/aws-xray-daemon:${{ github.event.inputs.version }} + amazon/aws-xray-daemon:latest + amazon/aws-xray-daemon:${{ github.event.inputs.major_version }} + push: true + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + - name: Create Release id: create_release uses: actions/create-release@v1 From fa8041f6e711e278e24e32c0327f290cfcb7c90a Mon Sep 17 00:00:00 2001 From: Prashant Srivastava Date: Fri, 16 Apr 2021 14:07:14 -0700 Subject: [PATCH 4/4] Updating continuous build wf as well --- .github/workflows/continuous-build.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-build.yml b/.github/workflows/continuous-build.yml index 6c30bc0..78b117f 100644 --- a/.github/workflows/continuous-build.yml +++ b/.github/workflows/continuous-build.yml @@ -123,15 +123,28 @@ jobs: restore-keys: | ${{ runner.os }}-buildx- - - name: Build docker image + - name: Build docker image for public ECR if: ${{ runner.os == 'Linux' }} uses: docker/build-push-action@v2 with: context: . + file: ./Dockerfile push: ${{ github.event_name == 'push' }} platforms: linux/amd64,linux/arm64 tags: | - amazon/aws-xray-daemon:alpha public.ecr.aws/xray/aws-xray-daemon:alpha cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Build docker image for DockerHub + if: ${{ runner.os == 'Linux' }} + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile.amazonlinux + push: ${{ github.event_name == 'push' }} + platforms: linux/amd64,linux/arm64 + tags: | + amazon/aws-xray-daemon:alpha + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache \ No newline at end of file