-
Notifications
You must be signed in to change notification settings - Fork 96
189 lines (183 loc) · 6.75 KB
/
rabbitmq-oci.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
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
# https://github.com/marketplace/actions/build-and-push-docker-images
name: RabbitMQ OCI
on:
pull_request:
workflow_dispatch:
inputs:
rabbitmq_ref:
description: The branch, tag or commit of rabbitmq-server to use
default: main
env:
REGISTRY_IMAGE: pivotalrabbitmq/rabbitmq
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build-package-generic-unix:
# Limit this workflow to branches in the main repository.
# Forks are unable to run this workflow because they don't
# have access to the docker login credentials.
if: github.repository == 'rabbitmq/ra'
runs-on: ubuntu-latest
outputs:
TAG_1: ${{ steps.tags.outputs.TAG_1 }}
TAG_2: ${{ steps.tags.outputs.TAG_2 }}
TAG_3: ${{ steps.tags.outputs.TAG_3 }}
TAG_4: ${{ steps.tags.outputs.TAG_4 }}
steps:
- name: Checkout RabbitMQ
uses: actions/checkout@v4
with:
repository: rabbitmq/rabbitmq-server
ref: ${{ github.event.inputs.rabbitmq_ref }}
- name: Checkout Ra
uses: actions/checkout@v4
with:
path: deps/ra
- name: Patch Ra version
working-directory: deps/ra
run: |
sed -r -i"_orig" '/vsn,/ s/".*"/"${{ github.event.pull_request.head.sha || github.sha }}"/' src/ra.app.src
if git diff --exit-code; then
exit 1
fi
- name: Configure Erlang
uses: erlef/setup-beam@v1
with:
otp-version: 26.2
elixir-version: 1.15
- name: make package-generic-unix
run: |
make package-generic-unix
- name: Upload package-generic-unix
uses: actions/upload-artifact@v4
with:
name: package-generic-unix
path: PACKAGES/rabbitmq-server-*.tar.xz
- name: Compute Tags
id: tags
run: |
OTP="$(erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), "releases", erlang:system_info(otp_release), "OTP_VERSION"])), io:fwrite(Version), halt().' -noshell)"
RABBIT_SHA=$(git rev-parse HEAD)
RABBIT_REF=$(git rev-parse --abbrev-ref HEAD)
RA_SHA=${{ github.event.pull_request.head.sha || github.sha }}
RA_ABBREV=ra-${RA_SHA:0:7}
TAG_1=rabbitmq-${RABBIT_REF}-${RA_ABBREV}-${OTP}
TAG_3=rabbitmq-${RABBIT_SHA:0:7}-${RA_ABBREV}-${OTP}
echo "TAG_1=$TAG_1" | tee -a $GITHUB_OUTPUT
echo "TAG_2=$TAG_2" | tee -a $GITHUB_OUTPUT
echo "TAG_3=$TAG_3" | tee -a $GITHUB_OUTPUT
echo "TAG_4=$TAG_4" | tee -a $GITHUB_OUTPUT
build:
needs: build-package-generic-unix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
# ARM64 are currently slow
# - linux/arm64
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
repository: rabbitmq/rabbitmq-server
ref: ${{ github.event.inputs.rabbitmq_ref }}
- name: Download package-generic-unix
uses: actions/download-artifact@v4
with:
name: package-generic-unix
path: PACKAGES
- name: Rename package-generic-unix
run: |
cp \
PACKAGES/rabbitmq-server-generic-unix-*.tar.xz \
packaging/docker-image/package-generic-unix.tar.xz
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_1 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_2 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_3 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_4 }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v5
with:
context: packaging/docker-image
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- build-package-generic-unix
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_1 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_2 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_3 }}
type=raw,value=${{ needs.build-package-generic-unix.outputs.TAG_4 }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}