-
Notifications
You must be signed in to change notification settings - Fork 17
276 lines (266 loc) · 11.4 KB
/
release_docker.yml
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: Publish Docker Images
on:
release:
types: [published]
workflow_dispatch:
inputs:
iota_node:
type: boolean
description: "Release iota-node image"
required: false
default: false
iota_indexer:
type: boolean
description: "Release iota-indexer image"
required: false
default: false
iota_tools:
type: boolean
description: "Release iota-tools image"
required: false
default: false
iota_graphql_rpc:
type: boolean
description: "Release iota-graphql-rpc image"
required: false
default: false
jobs:
prep-jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
# Initialize matrix array
matrix_array=()
# Check iota_node: true if the input is set to true and the event is workflow_dispatch,
# or if the event is a release (in which case the job should run regardless of the input).
if [ "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_node == 'true' || github.event_name == 'release' }}" == "true" ]; then
matrix_array+=("iota-node")
fi
# Check iota_indexer: true if the input is set to true and the event is workflow_dispatch,
# or if the event is a release (in which case the job should run regardless of the input).
if [ "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_indexer == 'true' || github.event_name == 'release' }}" == "true" ]; then
matrix_array+=("iota-indexer")
fi
# Check iota_tools: true if the input is set to true and the event is workflow_dispatch,
# or if the event is a release (in which case the job should run regardless of the input).
if [ "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_tools == 'true' || github.event_name == 'release' }}" == "true" ]; then
matrix_array+=("iota-tools")
fi
# Check iota_graphql_rpc: true if the input is set to true and the event is workflow_dispatch,
# or if the event is a release (in which case the job should run regardless of the input).
if [ "${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_graphql_rpc == 'true' || github.event_name == 'release' }}" == "true" ]; then
matrix_array+=("iota-graphql-rpc")
fi
# Convert matrix array to JSON and set it as output
echo "::set-output name=matrix::$(echo ${matrix_array[@]} | jq -R . | jq -s .)"
build-jobs:
needs: prep-jobs
strategy:
fail-fast: false
matrix:
job_name: ${{ fromJSON(needs.prep-jobs.outputs.matrix) }}
os: [
ubuntu-latest,
ubuntu-24.04-arm
]
runs-on: ${{ matrix.os }}
steps:
- name: Echo
run: echo "build ${{ matrix.job_name }} ${{ matrix.os }}"
merge-jobs:
needs: [prep-jobs, build-jobs]
strategy:
fail-fast: false
matrix:
job_name: ${{ fromJSON(needs.prep-jobs.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- name: Echo
run: echo "merge ${{ matrix.job_name }}"
# build-jobs:
# environment: release
# strategy:
# matrix:
# job_name:
# - iota-node
# - iota-indexer
# - iota-tools
# - iota-graphql-rpc
# os: [
# ubuntu-latest,
# ubuntu-24.04-arm
# ]
# include:
# - image_name: iota-node
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_node == 'true' || github.event_name == 'release' }}
# - image_name: iota-indexer
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_indexer == 'true' || github.event_name == 'release' }}
# - image_name: iota-tools
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_tools == 'true' || github.event_name == 'release' }}
# - image_name: iota-graphql-rpc
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_graphql_rpc == 'true' || github.event_name == 'release' }}
# fail-fast: false
# runs-on: ${{ matrix.os }}
# if: ${{ matrix.run }}
# steps:
# - name: Prepare
# run: |
# if [ "${{ runner.os }}" != "Linux" ]; then
# echo "Error: This workflow only supports Linux runners."
# exit 1
# fi
#
# case "${{ runner.arch }}" in
# X64)
# PLATFORM_ARCH="amd64"
# ;;
# ARM64)
# PLATFORM_ARCH="arm64"
# ;;
# *)
# echo "Error: Unsupported architecture: ${{ runner.arch }}"
# exit 1
# ;;
# esac
#
# echo "DOCKER_PLATFORM=linux/${PLATFORM_ARCH}" >> $GITHUB_ENV
# echo "PLATFORM_PAIR=linux-${PLATFORM_ARCH}" >> $GITHUB_ENV
#
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
# with:
# images: iotaledger/${{ matrix.image_name }}
#
# - name: Login to Docker Registry
# uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
# with:
# username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
# password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# registry: ${{ secrets.DOCKER_REGISTRY_URL }}
#
# - name: Set up QEMU
# uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
#
# - name: Checkout code
# uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
#
# - name: Read Rust toolchain version from TOML
# id: read-toolchain
# run: |
# TOOLCHAIN_VERSION=$(grep -oE 'channel = "[^"]+' ./rust-toolchain.toml | sed 's/channel = "//')
# echo "TOOLCHAIN_VERSION=${TOOLCHAIN_VERSION}" >> $GITHUB_ENV
#
# - name: Log Rust toolchain version
# run: echo "Rust toolchain version is ${{ env.TOOLCHAIN_VERSION }}"
#
# - name: Get git revision and build date
# id: git-info
# run: |
# echo "GIT_REVISION=$(git describe --always --abbrev=12 --dirty --exclude '*')" >> $GITHUB_ENV
# echo "BUILD_DATE=$(date -u +'%Y-%m-%d')" >> $GITHUB_ENV
#
# - name: Build and push by digest
# id: build
# uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
# with:
# context: .
# file: docker/${{ matrix.image_name }}/Dockerfile
# platforms: ${{ env.DOCKER_PLATFORM }}
# labels: ${{ steps.meta.outputs.labels }}
# outputs: type=image,"name=iotaledger/${{ matrix.image_name }}",push-by-digest=true,name-canonical=true,push=true
# build-args: |
# GIT_REVISION=${{ env.GIT_REVISION }}
# BUILD_DATE=${{ env.BUILD_DATE }}
# RUST_IMAGE_VERSION=${{ env.TOOLCHAIN_VERSION }}-bookworm
#
# - name: Export digest
# run: |
# mkdir -p ${{ runner.temp }}/digests-${{ matrix.image_name }}
# digest="${{ steps.build.outputs.digest }}"
# touch "${{ runner.temp }}/digests-${{ matrix.image_name }}/${digest#sha256:}"
#
# - name: Upload digest
# uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
# with:
# name: digests-${{ matrix.image_name }}-${{ env.PLATFORM_PAIR }}
# path: ${{ runner.temp }}/digests-${{ matrix.image_name }}/*
# if-no-files-found: error
# retention-days: 1
#
# merge-jobs:
# environment: release
# needs:
# - build-jobs
# strategy:
# matrix:
# image_name:
# - iota-node
# - iota-indexer
# - iota-tools
# - iota-graphql-rpc
# include:
# - image_name: iota-node
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_node == 'true' || github.event_name == 'release' }}
# - image_name: iota-indexer
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_indexer == 'true' || github.event_name == 'release' }}
# - image_name: iota-tools
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_tools == 'true' || github.event_name == 'release' }}
# - image_name: iota-graphql-rpc
# run: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.iota_graphql_rpc == 'true' || github.event_name == 'release' }}
# fail-fast: false
# runs-on: ubuntu-latest
# if: ${{ matrix.run }}
# steps:
# - name: Download digests
# uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
# with:
# path: ${{ runner.temp }}/digests-${{ matrix.image_name }}
# pattern: digests-${{ matrix.image_name }}-*
# merge-multiple: true
#
# - name: Login to Docker Registry
# uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
# with:
# username: ${{ secrets.DOCKER_REGISTRY_USERNAME }}
# password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
# registry: ${{ secrets.DOCKER_REGISTRY_URL }}
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
#
# - name: Docker meta
# id: meta
# uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
# with:
# images: iotaledger/${{ matrix.image_name }}
# # mapping semver tags to networks
# # v{MAJOR}.{MINOR}.{PATCH}-alpha -> alphanet
# # v{MAJOR}.{MINOR}.{PATCH}-beta -> devnet
# # v{MAJOR}.{MINOR}.{PATCH}-rc -> testnet
# # v{MAJOR}.{MINOR}.{PATCH} -> mainnet
# tags: |
# type=raw,value={{sha}},enable=${{ github.event_name == 'workflow_dispatch' }}
# type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' }}
# type=raw,value={{tag}},enable=${{ github.event_name == 'release' }}
# type=raw,value=alphanet,enable=${{ github.event_name == 'release' && contains(github.ref, '-alpha') }}
# type=raw,value=devnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-beta') }}
# type=raw,value=testnet,enable=${{ github.event_name == 'release' && contains(github.ref, '-rc') }}
# type=raw,value=mainnet,enable=${{ github.event_name == 'release' && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') }}
#
# - name: Create manifest list and push
# working-directory: ${{ runner.temp }}/digests-${{ matrix.image_name }}
# run: |
# docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
# $(printf 'iotaledger/${{ matrix.image_name }}@sha256:%s ' *)
#
# - name: Inspect image
# run: |
# docker buildx imagetools inspect iotaledger/${{ matrix.image_name }}:${{ steps.meta.outputs.version }}