From 420d556ff71fc971167c5b49acde55fe4d14bb50 Mon Sep 17 00:00:00 2001 From: ikawaha Date: Thu, 29 Oct 2020 11:49:44 +0900 Subject: [PATCH] Fix a release action --- .github/workflows/build-docker-release.yml | 88 ---------------------- .github/workflows/release.yml | 81 +++++++++++++++++++- .goreleaser.yml | 1 - 3 files changed, 80 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/build-docker-release.yml diff --git a/.github/workflows/build-docker-release.yml b/.github/workflows/build-docker-release.yml deleted file mode 100644 index d1d58064..00000000 --- a/.github/workflows/build-docker-release.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Docker Build Release - -on: - workflow_dispatch: - push: - tags: - - 'v*' - -env: - NAME_IMAGE: "${{ secrets.DOCKER_USERNAME }}/kagome" - -jobs: - docker: - runs-on: ubuntu-latest - steps: - # Clone and checkout the repo. "fetch-depth" is needed in order to get the - # version tag information. - - name: Checkout the code - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - # Install QEMU emulators for Buildx - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - with: - platforms: all - - # Install Buildx to build multi-arch docker images. - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - with: - version: latest - - # View available platforms - - name: Available platforms of Buildx - run: echo ${{ steps.buildx.outputs.platforms }} - - # Login to Docker Hub. You need to set the below two secreat env variables - # in the repo's [Settings]-[Secrets] settings in advance: - # DOCKER_USERNAME ... Login user name of Docker Hub - # DOCKER_PASSWORD ... Access Token from https://hub.docker.com/settings/security - - name: Login to DockerHub - if: success() && github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - # To make the "latest" tag work not only for x86_64(Intel/AMD) but with ARMs - # such as ARM v6, v7 and ARM64 architectures, we need a temporary workaround - # due to the bug of Docker. https://github.com/moby/moby/issues/37647 - - name: Build the images - # Build images for each architecture and push them. - run: | - docker system prune -f -a && \ - docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v6 --platform linux/arm/v6 --build-arg GOARCH=arm --build-arg GOARM=6 . && \ - docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v7 --platform linux/arm/v7 --build-arg GOARCH=arm --build-arg GOARM=7 . && \ - docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm64 --platform linux/arm64 --build-arg GOARCH=arm64 . && \ - docker buildx build --push --tag ${{ env.NAME_IMAGE }}:amd64 --platform linux/amd64 . - - name: Pull back the images - # We need to pull back the built images to use the manifest which Docker - # Hub did attach. - run: | - docker system prune -f -a && \ - docker pull ${{ env.NAME_IMAGE }}:arm32v6 && \ - docker pull ${{ env.NAME_IMAGE }}:arm32v7 && \ - docker pull ${{ env.NAME_IMAGE }}:arm64 && \ - docker pull ${{ env.NAME_IMAGE }}:amd64 - - name: Create current manifest and push - # Create manifest of current Kagome version with "vX.Y.Z" tag. - run: | - git_tag=$(git describe --tag) && \ - version_curr=$(echo "${git_tag}" | grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1) && \ - echo '- Removing latest image (prevent conflict)' && \ - docker image rm -f ${{ env.NAME_IMAGE }}:latest && \ - echo "- Creating manifest for Kagome version: ${version_curr}" && \ - export DOCKER_CLI_EXPERIMENTAL=enabled && \ - docker manifest create ${{ env.NAME_IMAGE }}:${version_curr} \ - ${{ env.NAME_IMAGE }}:arm32v6 \ - ${{ env.NAME_IMAGE }}:arm32v7 \ - ${{ env.NAME_IMAGE }}:arm64 \ - ${{ env.NAME_IMAGE }}:amd64 && \ - docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v6 --variant v6l && \ - docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v7 --variant v7l && \ - docker manifest inspect ${{ env.NAME_IMAGE }}:${version_curr} && \ - docker manifest push ${{ env.NAME_IMAGE }}:${version_curr} --purge diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1037fb11..009e20b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,8 @@ on: push: tags: - 'v*' +env: + NAME_IMAGE: "${{ secrets.DOCKER_USERNAME }}/kagome" jobs: goreleaser: @@ -24,4 +26,81 @@ jobs: version: latest args: release --rm-dist --config .goreleaser.yml env: - GITHUB_TOKEN: ${{ secrets.GO_RELEASER_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + docker: + runs-on: ubuntu-latest + steps: + # Clone and checkout the repo. "fetch-depth" is needed in order to get the + # version tag information. + - name: Checkout the code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + # Install QEMU emulators for Buildx + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + with: + platforms: all + + # Install Buildx to build multi-arch docker images. + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v1 + with: + version: latest + + # View available platforms + - name: Available platforms of Buildx + run: echo ${{ steps.buildx.outputs.platforms }} + + # Login to Docker Hub. You need to set the below two secreat env variables + # in the repo's [Settings]-[Secrets] settings in advance: + # DOCKER_USERNAME ... Login user name of Docker Hub + # DOCKER_PASSWORD ... Access Token from https://hub.docker.com/settings/security + - name: Login to DockerHub + if: success() && github.event_name != 'pull_request' + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # To make the "latest" tag work not only for x86_64(Intel/AMD) but with ARMs + # such as ARM v6, v7 and ARM64 architectures, we need a temporary workaround + # due to the bug of Docker. https://github.com/moby/moby/issues/37647 + - name: Build the images + # Build images for each architecture and push them. + run: | + docker system prune -f -a && \ + docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v6 --platform linux/arm/v6 --build-arg GOARCH=arm --build-arg GOARM=6 . && \ + docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v7 --platform linux/arm/v7 --build-arg GOARCH=arm --build-arg GOARM=7 . && \ + docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm64 --platform linux/arm64 --build-arg GOARCH=arm64 . && \ + docker buildx build --push --tag ${{ env.NAME_IMAGE }}:amd64 --platform linux/amd64 . + - name: Pull back the images + # We need to pull back the built images to use the manifest which Docker + # Hub did attach. + run: | + docker system prune -f -a && \ + docker pull ${{ env.NAME_IMAGE }}:arm32v6 && \ + docker pull ${{ env.NAME_IMAGE }}:arm32v7 && \ + docker pull ${{ env.NAME_IMAGE }}:arm64 && \ + docker pull ${{ env.NAME_IMAGE }}:amd64 + - name: Create current manifest and push + # Create manifest of current Kagome version with "vX.Y.Z" tag. + run: | + git_tag=$(git describe --tag) && \ + version_curr=$(echo "${git_tag}" | grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1) && \ + echo '- Removing latest image (prevent conflict)' && \ + docker image rm -f ${{ env.NAME_IMAGE }}:latest && \ + echo "- Creating manifest for Kagome version: ${version_curr}" && \ + export DOCKER_CLI_EXPERIMENTAL=enabled && \ + docker manifest create ${{ env.NAME_IMAGE }}:${version_curr} \ + ${{ env.NAME_IMAGE }}:arm32v6 \ + ${{ env.NAME_IMAGE }}:arm32v7 \ + ${{ env.NAME_IMAGE }}:arm64 \ + ${{ env.NAME_IMAGE }}:amd64 && \ + docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v6 --variant v6l && \ + docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v7 --variant v7l && \ + docker manifest inspect ${{ env.NAME_IMAGE }}:${version_curr} && \ + docker manifest push ${{ env.NAME_IMAGE }}:${version_curr} --purge diff --git a/.goreleaser.yml b/.goreleaser.yml index 6033bb21..5f10c078 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -11,7 +11,6 @@ builds: - darwin - windows goarch: - - 386 - amd64 - arm - arm64