forked from memgraph/memgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (131 loc) · 5.26 KB
/
release_mgbench_client.yaml
File metadata and controls
145 lines (131 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: "Mgbench Bolt Client Build and Publish Docker Image"
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
version:
description: "Mgbench bolt client version to publish on Dockerhub."
required: true
build_image:
type: choice
description: "Mgbench build image(s)"
options:
- all
- arm_client
- amd_client
- arm_full
- amd_full
default: all
push_to_dockerhub:
type: boolean
default: false
description: "Push images to dockerhub"
test_docker_push:
type: boolean
default: false
description: "Push to test repository on Dockerhub"
force_release:
type: boolean
required: false
default: false
description: "Overwrite existing images with the same tags"
upload_artifact:
type: boolean
description: "create downloadable artifact"
default: false
jobs:
build_images:
name: Build all images
if: ${{ inputs.build_image == 'all' }}
strategy:
fail-fast: false
matrix:
arch: [amd, arm]
image_type: [client, full]
uses: ./.github/workflows/reusable_build_mgbench_client.yml
with:
arch: ${{ matrix.arch }}
version: ${{ inputs.version }}
push_to_dockerhub: ${{ inputs.push_to_dockerhub }}
test_docker_push: ${{ inputs.test_docker_push }}
force_release: ${{ inputs.force_release }}
image_type: ${{ matrix.image_type }}
upload_artifact: ${{ inputs.upload_artifact }}
secrets: inherit
build_single_image:
name: Build single image
if: ${{ inputs.build_image != 'all' }}
uses: ./.github/workflows/reusable_build_mgbench_client.yml
with:
arch: ${{ startsWith(inputs.build_image, 'arm_') && 'arm' || 'amd' }}
version: ${{ inputs.version }}
push_to_dockerhub: ${{ inputs.push_to_dockerhub }}
test_docker_push: ${{ inputs.test_docker_push }}
force_release: ${{ inputs.force_release }}
image_type: ${{ endsWith(inputs.build_image, 'full') && 'full' || 'client' }}
upload_artifact: ${{ inputs.upload_artifact }}
secrets: inherit
cleanup_docker:
runs-on: ubuntu-latest
if: ${{ inputs.push_to_dockerhub }}
name: "Clean up Docker tags"
needs: build_images
env:
DOCKER_ORGANIZATION_NAME: memgraph
DOCKER_REPOSITORY_NAME: mgbench-client${{ inputs.test_docker_push && '-test' || '' }}
strategy:
fail-fast: false
matrix:
image_type: [client, full]
steps:
- name: Log in to Docker Hub
if: ${{ inputs.push_to_dockerhub }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push multi-arch manifest for version
run: |
if [[ "${{ matrix.image_type }}" == "client" ]]; then
repo_tag="$DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ inputs.version }}"
else
repo_tag="$DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:${{ inputs.version }}-full"
fi
repo_tag_arm="${repo_tag}-arm64"
repo_tag_amd="${repo_tag}-amd64"
echo "REPO_TAG=${repo_tag}" >> $GITHUB_ENV
echo "REPO_TAG_ARM=${repo_tag_arm}" >> $GITHUB_ENV
echo "REPO_TAG_AMD=${repo_tag_amd}" >> $GITHUB_ENV
- name: Create and push multi-arch manifest for version
run: |
# pull them
docker pull $REPO_TAG_ARM
docker pull $REPO_TAG_AMD
# create version manifest
docker manifest create $REPO_TAG \
$REPO_TAG_ARM $REPO_TAG_AMD
docker manifest annotate $REPO_TAG $REPO_TAG_ARM --os linux --arch arm64
docker manifest annotate $REPO_TAG $REPO_TAG_AMD --os linux --arch amd64
docker manifest push $REPO_TAG
- name: Tag latest client image
if: ${{ matrix.image_type == 'client' }}
run: |
LATEST_TAG="$DOCKER_ORGANIZATION_NAME/$DOCKER_REPOSITORY_NAME:latest"
docker manifest create $LATEST_TAG $REPO_TAG_AMD $REPO_TAG_ARM
docker manifest annotate $LATEST_TAG $REPO_TAG_ARM --os linux --arch arm64
docker manifest annotate $LATEST_TAG $REPO_TAG_AMD --os linux --arch amd64
docker manifest push $LATEST_TAG
- name: Get dockerhub token
run: |
dockerhub_token=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "${{ secrets.DOCKERHUB_USERNAME }}", "password": "${{ secrets.DOCKERHUB_TOKEN }}"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
echo "dockerhub_token=${dockerhub_token}" >> $GITHUB_ENV
- name: Delete single-arch tags
run: |
for t in "${REPO_TAG_ARM#*:}" "${REPO_TAG_AMD#*:}"; do
url="https://hub.docker.com/v2/repositories/${DOCKER_ORGANIZATION_NAME}/${DOCKER_REPOSITORY_NAME}/tags/$t/"
echo "Deleting tag → $t from $url"
curl -i -n -X DELETE -H "Authorization: JWT ${dockerhub_token}" \
"https://hub.docker.com/v2/repositories/${DOCKER_ORGANIZATION_NAME}/${DOCKER_REPOSITORY_NAME}/tags/$t/"
done