forked from hyperledger/fabric-x-committer
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (112 loc) · 4.79 KB
/
Copy pathdocker-release.yml
File metadata and controls
128 lines (112 loc) · 4.79 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
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#
name: Release Fabric-X Committer Docker Image
on:
push:
tags:
- "v*" # Trigger on tags like v0.0.1
permissions:
contents: read
packages: write
jobs:
docker-release:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up QEMU (for cross-platform builds)
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract and Validate Version from Tag
id: extract
run: |
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "✅ Tag validated: $VERSION"
else
echo "❌ Invalid tag format: ${GITHUB_REF}. Expected format: refs/tags/v<semver>"
exit 1
fi
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install dev dependencies
run: scripts/install-dev-dependencies.sh
- name: Build cross-architecture binaries
run: make build-arch build-test-genesis-block
- name: Set image prefix
run: |
if [ "$GITHUB_REPOSITORY_OWNER" == "hyperledger" ]; then
echo "IMAGE_PREFIX=hyperledger" >> $GITHUB_ENV
else
echo "IMAGE_PREFIX=${{ secrets.DOCKERHUB_USERNAME }}" >> $GITHUB_ENV
fi
echo "GHCR_PREFIX=$GITHUB_REPOSITORY_OWNER" >> $GITHUB_ENV
- name: Build and Push Multi-Platform Docker Image for Committer
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/images/release/Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: |
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:${{ env.VERSION }}
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:latest
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-committer:${{ env.VERSION }}
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-committer:latest
build-args: |
BIN=committer
ARCHBIN_PATH=archbin
PORTS=4001 2114 9001 2119 5001 2115 6001 2116 7001 2117
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:buildcache
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer:buildcache,mode=max
- name: Build and Push Multi-Platform Docker Image for Loadgen
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/images/release/Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: |
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:${{ env.VERSION }}
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:latest
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-loadgen:${{ env.VERSION }}
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-loadgen:latest
build-args: |
BIN=loadgen
ARCHBIN_PATH=archbin
PORTS=8001 2118
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:buildcache
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-loadgen:buildcache,mode=max
- name: Build and Push Multi-Platform Docker Image for Committer's Test Node
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/images/test_node/Dockerfile
platforms: linux/amd64,linux/arm64,linux/s390x
push: true
tags: |
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:${{ env.VERSION }}
docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:latest
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-committer-test-node:${{ env.VERSION }}
ghcr.io/${{ env.GHCR_PREFIX }}/fabric-x-committer-test-node:latest
build-args: |
ARCHBIN_PATH=archbin
cache-from: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:buildcache
cache-to: type=registry,ref=docker.io/${{ env.IMAGE_PREFIX }}/fabric-x-committer-test-node:buildcache,mode=max