forked from dragonflydb/dragonfly
-
Notifications
You must be signed in to change notification settings - Fork 0
228 lines (198 loc) · 7.35 KB
/
docker-release2.yml
File metadata and controls
228 lines (198 loc) · 7.35 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Docker Release-v2
on:
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true
PRERELEASE:
description: 'Whether this is a prerelease'
type: boolean
required: true
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
IS_PRERELEASE: ${{ github.event.release.prerelease || github.event.inputs.PRERELEASE }}
IMAGE: ghcr.io/dragonflydb/dragonfly
jobs:
build_and_tag:
name: Build and Push ${{matrix.flavor}} ${{ matrix.os.arch }} image
strategy:
matrix:
flavor: [ubuntu]
os:
- image: ubuntu-24.04
arch: amd64
- image: ubuntu-24.04-arm
arch: arm64
runs-on: ${{ matrix.os.image }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch release asset
uses: dsaltares/fetch-gh-release-asset@1.1.2
with:
version: "tags/${{ env.TAG_NAME }}"
regex: true
file: "dragonfly-.*\\.tar\\.gz"
target: 'releases/'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Extract artifacts
run: |
echo "Event prerelease ${{ github.event.release.prerelease }}"
echo "Input prerelease ${{ github.event.inputs.PRERELEASE }}"
ls -l
ls -l releases
for f in releases/*.tar.gz; do tar xvfz $f -C releases; done
rm releases/*.tar.gz
- name: Docker meta
id: metadata
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE }}
flavor: |
latest=false
prefix=${{ matrix.flavor}}-
suffix=-${{ matrix.os.arch }}
tags: |
type=semver,pattern={{version}},enable=true,value=${{ env.TAG_NAME }}
type=semver,pattern={{raw}},enable=true,value=${{ env.TAG_NAME }}
type=ref,event=pr
labels: |
org.opencontainers.image.vendor=DragonflyDB LTD
org.opencontainers.image.title=Dragonfly Production Image
org.opencontainers.image.description=The fastest in-memory store
- name: Build image
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
provenance: false # Prevent pushing a docker manifest
tags: |
${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
file: tools/packaging/Dockerfile.${{ matrix.flavor }}-prod
cache-from: type=gha,scope=prod-${{ matrix.flavor }}
cache-to: type=gha,scope=prod-${{ matrix.flavor }},mode=max
load: true # Load the build images into the local docker.
- name: Test Image
uses: ./.github/actions/test-docker
timeout-minutes: 1
with:
image_id: ${{ env.IMAGE }}@${{ steps.build.outputs.digest }}
name: ${{ matrix.flavor }}-${{ matrix.os.arch }}
- id: output-sha
run: |
echo "sha_${{ matrix.os.arch }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
outputs:
sha_amd: ${{ steps.output-sha.outputs.sha_amd64 }}
sha_arm: ${{ steps.output-sha.outputs.sha_arm64 }}
merge_manifest:
needs: [build_and_tag]
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [ubuntu]
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Merge and Push
run: |
sha_amd=${{ env.IMAGE }}@${{ needs.build_and_tag.outputs.sha_amd }}
sha_arm=${{ env.IMAGE }}@${{ needs.build_and_tag.outputs.sha_arm }}
echo "shas: $sha_amd $sha_arm"
if [[ "${{ env.IS_PRERELEASE }}" == 'true' ]]; then
# Create and push the manifest like dragonfly:alpha-ubuntu
tag="${{ env.IMAGE }}:alpha-${{ matrix.flavor }}"
docker manifest create ${tag} --amend ${sha_amd} --amend ${sha_arm}
docker manifest push ${tag}
elif [[ "${{matrix.flavor}}" == 'ubuntu' ]]; then
tag="${{ env.IMAGE }}:latest"
# Create and push the manifest like dragonfly:latest
docker manifest create ${tag} --amend ${sha_amd} --amend ${sha_arm}
docker manifest push ${tag}
fi
# Create and push the manifest like dragonfly:v1.26.4
tag=${{ env.IMAGE }}:${{ env.TAG_NAME }}
docker manifest create ${tag} --amend ${sha_amd} --amend ${sha_arm}
docker manifest push ${tag}
release_helm_and_notify:
needs: [merge_manifest]
runs-on: ubuntu-latest
steps:
- name: print_env
run: env
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install helm
uses: azure/setup-helm@v4
- name: Setup Go
uses: actions/setup-go@v5
- name: Configure Git
if: env.IS_PRERELEASE != 'true'
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Update helm chart
if: env.IS_PRERELEASE != 'true'
run: |
git checkout main
sed -Ei \
-e 's/^(version\:) .*/\1 '${{ env.TAG_NAME }}'/g' \
-e 's/^(appVersion\:) .*/\1 "'${{ env.TAG_NAME }}'"/g' \
contrib/charts/dragonfly/Chart.yaml
go test ./contrib/charts/dragonfly/... -update
git commit \
-m 'chore(helm-chart): update to ${{ env.TAG_NAME }}' \
contrib/charts/dragonfly/Chart.yaml \
contrib/charts/dragonfly/ci || true
- name: Push Helm chart as OCI to Github
if: env.IS_PRERELEASE != 'true'
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | \
helm registry login -u ${{ github.actor }} --password-stdin ghcr.io
helm package contrib/charts/dragonfly
helm push dragonfly-${{ env.TAG_NAME }}.tgz oci://ghcr.io/${{ github.repository }}/helm
- name: GitHub Push
uses: CasperWA/push-protected@v2
if: env.IS_PRERELEASE != 'true'
with:
token: ${{ secrets.DRAGONFLY_TOKEN }}
branch: main
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9
with:
args: 'DragonflyDB version [${{ env.TAG_NAME }}](https://github.com/dragonflydb/dragonfly/releases/tag/${{ env.TAG_NAME }}) has been released 🎉'
- name: Re-build Docs
if: env.IS_PRERELEASE != 'true'
run: |
curl -s -X POST '${{ secrets.VERCEL_DOCS_WEBHOOK }}'