1
1
name : Release
2
2
3
3
on :
4
+ workflow_dispatch :
4
5
push :
5
6
tags :
6
7
- ' v*'
7
- env :
8
- NAME_IMAGE : " ${{ secrets.DOCKER_USERNAME }}/kagome"
9
8
10
9
jobs :
11
10
goreleaser :
@@ -14,93 +13,36 @@ jobs:
14
13
- name : Checkout
15
14
uses : actions/checkout@v3
16
15
with :
16
+ # required for the changelog of goreleaser to work correctly.
17
17
fetch-depth : 0
18
+
19
+ # Setup Go
18
20
- name : Set up Go
19
21
uses : actions/setup-go@v4
20
22
with :
21
23
go-version-file : ' go.mod'
22
24
cache : true
23
- - name : Run GoReleaser
24
- uses : goreleaser/goreleaser-action@v4
25
- with :
26
- version : latest
27
- args : release --rm-dist --config .goreleaser.yml
28
- env :
29
- GITHUB_TOKEN : ${{ secrets.GO_RELEASER_TOKEN }}
30
25
31
- docker :
32
- runs-on : ubuntu-latest
33
- steps :
34
- # Clone and checkout the repo. "fetch-depth" is needed in order to get the
35
- # version tag information.
36
- - name : Checkout the code
37
- uses : actions/checkout@v3
38
- with :
39
- fetch-depth : 0
40
-
41
- # Install QEMU emulators for Buildx
26
+ # Multiarch build
42
27
- name : Set up QEMU
43
28
uses : docker/setup-qemu-action@v2
44
- with :
45
- platforms : all
46
29
47
- # Install Buildx to build multi-arch docker images.
48
30
- name : Set up Docker Buildx
49
31
id : buildx
50
32
uses : docker/setup-buildx-action@v2
51
- with :
52
- version : latest
53
-
54
- # View available platforms
55
- - name : Available platforms of Buildx
56
- run : echo ${{ steps.buildx.outputs.platforms }}
57
33
58
- # Login to Docker Hub. You need to set the below two secreat env variables
59
- # in the repo's [Settings]-[Secrets] settings in advance:
60
- # DOCKER_USERNAME ... Login user name of Docker Hub
61
- # DOCKER_PASSWORD ... Access Token from https://hub.docker.com/settings/security
62
- - name : Login to DockerHub
63
- if : success() && github.event_name != 'pull_request'
34
+ # Login to DockerHub before push.
35
+ - name : Login to Docker Hub
64
36
uses : docker/login-action@v2
65
37
with :
66
38
username : ${{ secrets.DOCKER_USERNAME }}
67
39
password : ${{ secrets.DOCKER_PASSWORD }}
68
40
69
- # To make the "latest" tag work not only for x86_64(Intel/AMD) but with ARMs
70
- # such as ARM v6, v7 and ARM64 architectures, we need a temporary workaround
71
- # due to the bug of Docker. https://github.com/moby/moby/issues/37647
72
- - name : Build the images
73
- # Build images for each architecture and push them.
74
- run : |
75
- docker system prune -f -a && \
76
- docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v6 --platform linux/arm/v6 --build-arg GOARCH=arm --build-arg GOARM=6 . && \
77
- docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm32v7 --platform linux/arm/v7 --build-arg GOARCH=arm --build-arg GOARM=7 . && \
78
- docker buildx build --push --tag ${{ env.NAME_IMAGE }}:arm64 --platform linux/arm64 --build-arg GOARCH=arm64 . && \
79
- docker buildx build --push --tag ${{ env.NAME_IMAGE }}:amd64 --platform linux/amd64 .
80
- - name : Pull back the images
81
- # We need to pull back the built images to use the manifest which Docker
82
- # Hub did attach.
83
- run : |
84
- docker system prune -f -a && \
85
- docker pull ${{ env.NAME_IMAGE }}:arm32v6 && \
86
- docker pull ${{ env.NAME_IMAGE }}:arm32v7 && \
87
- docker pull ${{ env.NAME_IMAGE }}:arm64 && \
88
- docker pull ${{ env.NAME_IMAGE }}:amd64
89
- - name : Create current manifest and push
90
- # Create manifest of current Kagome version with "vX.Y.Z" tag.
91
- run : |
92
- git_tag=$(git describe --tag) && \
93
- version_curr=$(echo "${git_tag}" | grep -o -E "(v[0-9]+\.){1}[0-9]+(\.[0-9]+)?" | head -n1) && \
94
- echo '- Removing latest image (prevent conflict)' && \
95
- docker image rm -f ${{ env.NAME_IMAGE }}:latest && \
96
- echo "- Creating manifest for Kagome version: ${version_curr}" && \
97
- export DOCKER_CLI_EXPERIMENTAL=enabled && \
98
- docker manifest create ${{ env.NAME_IMAGE }}:${version_curr} \
99
- ${{ env.NAME_IMAGE }}:arm32v6 \
100
- ${{ env.NAME_IMAGE }}:arm32v7 \
101
- ${{ env.NAME_IMAGE }}:arm64 \
102
- ${{ env.NAME_IMAGE }}:amd64 && \
103
- docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v6 --variant v6l && \
104
- docker manifest annotate ${{ env.NAME_IMAGE }}:${version_curr} ${{ env.NAME_IMAGE }}:arm32v7 --variant v7l && \
105
- docker manifest inspect ${{ env.NAME_IMAGE }}:${version_curr} && \
106
- docker manifest push ${{ env.NAME_IMAGE }}:${version_curr} --purge
41
+ # Build and release
42
+ - name : Run GoReleaser
43
+ uses : goreleaser/goreleaser-action@v4
44
+ with :
45
+ version : latest
46
+ args : release --config .goreleaser.yml --clean
47
+ env :
48
+ GITHUB_TOKEN : ${{ secrets.GO_RELEASER_TOKEN }}
0 commit comments