Skip to content

Commit

Permalink
Merge pull request #219 from ikawaha/fix/workflows/releaser_20201029
Browse files Browse the repository at this point in the history
Fix a release action
  • Loading branch information
ikawaha authored Oct 29, 2020
2 parents 4192b8f + 420d556 commit 48b08ae
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 90 deletions.
88 changes: 0 additions & 88 deletions .github/workflows/build-docker-release.yml

This file was deleted.

81 changes: 80 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
tags:
- 'v*'
env:
NAME_IMAGE: "${{ secrets.DOCKER_USERNAME }}/kagome"

jobs:
goreleaser:
Expand All @@ -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
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ builds:
- darwin
- windows
goarch:
- 386
- amd64
- arm
- arm64
Expand Down

0 comments on commit 48b08ae

Please sign in to comment.