-
Notifications
You must be signed in to change notification settings - Fork 28
152 lines (142 loc) · 6.64 KB
/
promote_rc_release.yaml
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
146
147
148
149
150
151
152
name: Promote RC to Release
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
mage_version:
description: "Mage version (format: X.Y.Z)"
required: true
type: string
mage_rc_version:
description: "Mage RC version to promote (format: rcX)"
required: false
type: string
memgraph_version:
description: "Memgraph version (format: X.Y.Z)"
required: true
type: string
force_promote:
type: boolean
description: "Override existing release"
default: false
test:
description: "Run in test mode"
required: false
type: boolean
env:
s3_region: eu-west-1
rc_bucket: deps.memgraph.io
rc_dir: mage/v${{ github.event.inputs.mage_version }}-${{ github.event.inputs.mage_rc_version }}
docker_repo_rc: memgraph/memgraph-mage
docker_repo_release: memgraph/memgraph-mage${{ github.event.inputs.test == 'true' && '-release-test' || '' }}
jobs:
PromoteDocker:
strategy:
fail-fast: false
matrix:
include:
- build_target: "prod"
build_scope: "with ML"
build_type: "Release"
- build_target: "prod"
build_scope: "with ML"
build_type: "RelWithDebInfo"
image_ext: "-relwithdebinfo"
- build_target: "prod"
build_scope: "without ML"
build_type: "Release"
image_ext: "-no-ml"
- build_target: "prod"
build_scope: "without ML"
build_type: "RelWithDebInfo"
image_ext: "-no-ml-relwithdebinfo"
- build_target: "dev"
build_scope: "with ML"
build_type: "RelwithDebInfo"
image_ext: "-dev"
runs-on: ${{ matrix.build_target == 'dev' && 'ubuntu-large' || 'ubuntu-latest' }}
steps:
- name: Setup environment variables
run: |
mage_version=${{ github.event.inputs.mage_version }}
memgraph_version=${{ github.event.inputs.memgraph_version }}
echo "docker_tar_amd=mage-${mage_version%.0}-memgraph-${memgraph_version%.0}${{ matrix.image_ext }}.tar.gz" >> $GITHUB_ENV
echo "docker_tar_arm=mage-${mage_version%.0}-memgraph-${memgraph_version%.0}-arm${{ matrix.image_ext }}.tar.gz" >> $GITHUB_ENV
echo "rc_image=${docker_repo_rc}:${mage_version%.0}-memgraph-${memgraph_version%.0}${{ matrix.image_ext }}" >> $GITHUB_ENV
echo "release_image=${docker_repo_release}:${mage_version%.0}-memgraph-${memgraph_version%.0}${{ matrix.image_ext }}" >> $GITHUB_ENV
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.s3_region }}
- name: Check if rc image for this build exists
run: |
if ! aws s3 ls s3://${rc_bucket}/${rc_dir}/${docker_tar_amd} &> /dev/null; then
echo "RC package does not exist at s3://${rc_bucket}/${rc_dir}/${docker_tar_amd}"
exit 1
elif ! aws s3 ls s3://${rc_bucket}/${rc_dir}/${docker_tar_arm} &> /dev/null; then
echo "RC package does not exist at s3://${rc_bucket}/${rc_dir}/${docker_tar_arm}"
exit 1
fi
- name: Check if release image for this build aldready exists
run: |
if docker manifest inspect ${release_image} &> /dev/null; then
echo "Release image ${release_image} already exists on DockerHub"
if [[ "${{ github.event.inputs.force_promote }}" != "true" ]]; then
echo "Set force_promote to true to override existing release!"
exit 1
fi
echo "Forcing promotion of existing release ..."
fi
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- 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: Promote RC to Release
run: |
release_image_amd=${release_image}-amd64
release_image_arm=${release_image}-arm64
release_image_latest=${docker_repo_release}:latest
# Download and load, retag if necessary, push temporary image
# arm64
echo "Downloading and loading ${rc_image} for arm ..."
aws s3 cp s3://${rc_bucket}/${rc_dir}/${docker_tar_arm} - | docker load
echo "Tagging ${rc_image} as ${release_image_arm} ..."
docker tag ${rc_image} ${release_image_arm}
echo "Pushing ${release_image_arm} to DockerHub!"
docker push ${release_image_arm}
# amd64
echo "Downloading and loading ${rc_image} for amd ..."
aws s3 cp s3://${rc_bucket}/${rc_dir}/${docker_tar_amd} - | docker load
echo "Tagging ${rc_image} as ${release_image_amd} ..."
docker tag ${rc_image} ${release_image_amd}
echo "Pushing ${release_image_amd} to DockerHub!"
docker push ${release_image_amd}
# Setup manifest list for release image
docker manifest create ${release_image} \
--amend ${release_image_amd} \
--amend ${release_image_arm}
docker manifest push ${release_image}
echo "Successfully published ${release_image} to DockerHub!"
# Setup manifest list for latest image if production image
if [[ -z "${{ matrix.image_ext }}" ]]; then
docker manifest create ${release_image_latest} \
--amend ${release_image_amd} \
--amend ${release_image_arm}
docker manifest push ${release_image_latest}
echo "Successfully published ${release_image_latest} to DockerHub!"
fi
- name: Clean up temporary images
run: |
echo "Deleting temporary image ${release_image_amd} ..."
curl -i -n -X DELETE -H "Authorization: JWT ${dockerhub_token}" https://hub.docker.com/v2/repositories/${docker_repo_release}/tags/${release_image#*:}-amd64/
echo "Deleting temporary image ${release_image_arm} ..."
curl -i -n -X DELETE -H "Authorization: JWT ${dockerhub_token}" https://hub.docker.com/v2/repositories/${docker_repo_release}/tags/${release_image#*:}-arm64/