-
Notifications
You must be signed in to change notification settings - Fork 707
220 lines (184 loc) · 7.34 KB
/
release.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
# Copyright the Hyperledger Fabric contributors. All rights reserved.
#
# SPDX-License-Identifier: Apache-2.0
name: Release
on:
push:
tags: [ v1.* ]
env:
GO_VER: 1.23.5
UBUNTU_VER: 22.04
IMAGE_NAME: ${{ github.repository }}
FABRIC_CA_VER: ${{ github.ref_name }}
permissions:
contents: read
jobs:
build-binaries:
name: Build Fabric CA Binaries
strategy:
matrix:
include:
- image: ubuntu-22.04
platform: linux-amd64
- image: ubuntu-22.04
platform: linux-arm64
- image: macos-14
platform: darwin-arm64
- image: macos-13
platform: darwin-amd64
- image: windows-2022
platform: windows-amd64
runs-on: ${{ matrix.image }}
steps:
- uses: actions/checkout@v4
name: Checkout Fabric CA Code
- uses: actions/setup-go@v5
name: Install Go
with:
go-version: ${{ env.GO_VER }}
- name: Install GCC cross-compilers
if: ${{ contains(matrix.platform, 'linux') }}
run: |
sudo apt-get update
sudo apt-get -y install gcc-aarch64-linux-gnu
sudo apt-get -y install gcc-x86-64-linux-gnu
- run: make dist/${{ matrix.platform }}
name: Compile Binary and Create Tarball
env:
BASE_VERSION: ${{ env.FABRIC_CA_VER }}
- uses: actions/upload-artifact@v4
name: Publish Release Artifacts
with:
# <name> of the artifact must not collide between platform/arch builds
name: release-${{ matrix.platform }}
# <path> of the artifact may include multiple files.
path: release/${{ matrix.platform }}/*.tar.gz
# build native image using a different runner for each architecture (faster and more reliable than using qemu to build multi-architecture images on ubuntu-22.04)
build-and-push-native-docker-images:
name: Build and Push native image
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
runner:
- ubuntu-22.04 # creates linux-amd64 images
- ubuntu-22.04-arm # creates linux-arm64 images
# Dynamic matrix
# If owner is 'hyperledger' run job for Docker Hub and ghcr, otherwise for personal forks just run job for ghcr
registry: ${{ fromJSON(github.repository_owner == 'hyperledger' && '["docker.io", "ghcr.io"]' || '["ghcr.io"]') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to the ${{ matrix.registry }} Container Registry
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.registry }}/${{ env.IMAGE_NAME }}
- name: Build and push
id: build-and-push
uses: docker/build-push-action@v6
with:
context: .
file: images/fabric-ca/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
build-args: |
UBUNTU_VER=${{ env.UBUNTU_VER }}
GO_VER=${{ env.GO_VER }}
GO_TAGS=pkcs11
GO_LDFLAGS=-X github.com/hyperledger/fabric-ca/lib/metadata.Version=${{ env.FABRIC_CA_VER }}
outputs: type=image,"name=${{ matrix.registry }}/${{ env.IMAGE_NAME }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests/${{ matrix.registry }}
digest="${{ steps.build-and-push.outputs.digest }}"
touch "${{ runner.temp }}/digests/${{ matrix.registry }}/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.registry }}-${{ matrix.runner }}
path: ${{ runner.temp }}/digests/${{ matrix.registry }}/*
if-no-files-found: error
retention-days: 1
# This job merges the architecture-specific digests for the images created above
# and creates a multi-architecture image manifest with user-friendly tags
merge-and-push-multi-arch-image:
name: Merge and Push multi-arch image
runs-on: ubuntu-22.04
needs:
- build-and-push-native-docker-images
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
# Dynamic matrix
# If owner is 'hyperledger' run job for Docker Hub and ghcr, otherwise for personal forks just run job for ghcr
registry: ${{ fromJSON(github.repository_owner == 'hyperledger' && '["docker.io", "ghcr.io"]' || '["ghcr.io"]') }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests/${{ matrix.registry }}
pattern: digests-${{ matrix.registry }}-*
merge-multiple: true
- name: Login to the ${{ matrix.registry }} Container Registry
uses: docker/login-action@v3
with:
registry: ${{ matrix.registry }}
username: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }}
password: ${{ matrix.registry == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.registry }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
- name: Create manifest list and push # combines the downloaded amd64 and arm64 digests and pushes multi-architecture manifest with the tags specified above
working-directory: ${{ runner.temp }}/digests/${{ matrix.registry }}
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ matrix.registry }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ matrix.registry }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
create-release:
name: Create GitHub Release
needs:
- build-binaries
- merge-and-push-multi-arch-image
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout Fabric CA Code
uses: actions/checkout@v4
- name: Download Artifacts
id: download
uses: actions/download-artifact@v4
with:
pattern: "release-*"
- name: Release Fabric CA Version
uses: ncipollo/release-action@v1
with:
allowUpdates: "true"
artifacts: "release-*-*/*.tar.gz"
bodyFile: release_notes/${{ env.FABRIC_CA_VER }}.md
tag: ${{ env.FABRIC_CA_VER }}
token: ${{ secrets.GITHUB_TOKEN }}