33# SPDX-License-Identifier: Apache-2.0
44
55name : Release
6+
67on :
7- workflow_dispatch :
8- inputs :
9- release :
10- description : ' Fabric Release, e.g. 2.4.7'
11- required : true
12- type : string
13- two_digit_release :
14- description : ' Fabric Two Digit Release, e.g. 2.4'
15- required : true
16- type : string
17- commit_hash :
18- description : ' Commit hash, e.g. df9c661a192f8cf11376d9d643a0021f1a76c34b'
19- required : true
20- type : string
8+ push :
9+ tags : [ v2.* ]
2110
2211env :
2312 GO_VER : 1.18.7
13+ ALPINE_VER : 3.16
14+ FABRIC_VER : ${{ github.ref_name }}
15+ DOCKER_REGISTRY : ghcr.io
2416
2517permissions :
2618 contents : read
3426 - image : ubuntu-20.04
3527 target : linux
3628 arch : amd64
29+ - image : ubuntu-20.04
30+ target : linux
31+ arch : arm64
3732 - image : macos-11
3833 target : darwin
3934 arch : amd64
35+ - image : macos-11
36+ target : darwin
37+ arch : arm64
4038 - image : windows-2022
4139 target : windows
4240 arch : amd64
@@ -52,38 +50,95 @@ jobs:
5250 run : ./ci/scripts/create_binary_package.sh
5351 env :
5452 TARGET : ${{ matrix.target }}-${{ matrix.arch }}
55- RELEASE : ${{ inputs.release }}
53+ RELEASE : ${{ env.FABRIC_VER }}
54+
5655 - name : Publish Release Artifact
5756 uses : actions/upload-artifact@v3
5857 with :
59- name : hyperledger-fabric-${{ matrix.target }}-${{ matrix.arch }}-${{ inputs.release }}.tar.gz
60- path : release/${{ matrix.target }}-${{ matrix.arch }}/hyperledger-fabric-${{ matrix.target }}-${{ matrix.arch }}-${{ inputs.release }}.tar.gz
58+ # <name> of the artifact must not collide between platform/arch builds
59+ name : release-${{ matrix.target }}-${{ matrix.arch }}
60+ # <path> of the artifact may include multiple files.
61+ path : release/${{ matrix.target }}-${{ matrix.arch }}/*.tar.gz
62+
6163 build-and-push-docker-images :
62- name : Build and Push Fabric Docker Images
64+ name : Build and Push
6365 runs-on : ubuntu-20.04
66+
67+ permissions :
68+ contents : read
69+ packages : write
70+
71+ strategy :
72+ matrix :
73+ include :
74+ - COMPONENT : baseos
75+ CONTEXT : images/baseos
76+ - COMPONENT : ccenv
77+ CONTEXT : images/ccenv
78+ - COMPONENT : peer
79+ CONTEXT : .
80+ - COMPONENT : orderer
81+ CONTEXT : .
82+ - COMPONENT : tools
83+ CONTEXT : .
84+
6485 steps :
65- - name : Run APT Clean
66- run : sudo apt clean
67- - name : Run Apt Update
68- run : sudo apt update
69- - name : Install Dependencies
70- run : sudo apt install -y gcc haveged libtool make
71- - name : Install Go
72- uses : actions/setup-go@v3
86+ - name : Set up QEMU
87+ uses : docker/setup-qemu-action@v2
88+
89+ - name : Set up Docker Buildx
90+ uses : docker/setup-buildx-action@v2
7391 with :
74- go-version : ${{ env.GO_VER }}
75- - name : Checkout Fabric Code
92+ buildkitd-flags : --debug
93+ config-inline : |
94+ [worker.oci]
95+ max-parallelism = 1
96+
97+ - name : Checkout
7698 uses : actions/checkout@v3
77- - name : Publish Docker Images
78- run : ./ci/scripts/publish_docker.sh
79- env :
80- RELEASE : ${{ inputs.release }}
81- TWO_DIGIT_RELEASE : ${{ inputs.two_digit_release }}
82- DOCKER_PASSWORD : ${{ secrets.DOCKERHUB_TOKEN }}
83- DOCKER_USERNAME : ${{ secrets.DOCKERHUB_USERNAME }}
99+
100+ - name : Login to the GitHub Container Registry
101+ uses : docker/login-action@v2
102+ with :
103+ registry : ${{ env.DOCKER_REGISTRY }}
104+ username : ${{ github.actor }}
105+ password : ${{ secrets.GITHUB_TOKEN }}
106+
107+ # For the docker hub registry:
108+ # username: ${{ secrets.DOCKERHUB_USERNAME }}
109+ # password: ${{ secrets.DOCKERHUB_TOKEN }}
110+
111+ - name : Docker meta
112+ id : meta
113+ uses : docker/metadata-action@v4
114+ with :
115+ images : ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-${{ matrix.COMPONENT }}
116+ tags : |
117+ type=semver,pattern={{version}}
118+ type=semver,pattern={{major}}.{{minor}}
119+ type=semver,pattern={{major}}.{{minor}}.{{patch}}
120+
121+ - name : Build and push ${{ matrix.COMPONENT }} Image
122+ id : push
123+ uses : docker/build-push-action@v3
124+ with :
125+ context : ${{ matrix.CONTEXT }}
126+ file : images/${{ matrix.COMPONENT }}/Dockerfile
127+ platforms : linux/amd64,linux/arm64
128+ tags : ${{ steps.meta.outputs.tags }}
129+ push : ${{ github.event_name != 'pull_request' }}
130+ labels : ${{ steps.meta.outputs.labels }}
131+ build-args : |
132+ FABRIC_VER=${{ env.FABRIC_VER }}
133+ ALPINE_VER=${{ env.ALPINE_VER }}
134+ GO_VER=${{ env.GO_VER }}
135+ GO_TAGS=
136+
84137 create-release :
85138 name : Create GitHub Release
86- needs : [ build-binaries, build-and-push-docker-images ]
139+ needs :
140+ - build-binaries
141+ - build-and-push-docker-images
87142 runs-on : ubuntu-20.04
88143 permissions :
89144 contents : write
96151 - name : Release Fabric Version
97152 uses : ncipollo/release-action@v1
98153 with :
99- artifacts : " *.tar.gz/*.tar.gz "
100- bodyFile : release_notes/v${{ inputs.release }}.md
101- commit : ${{ inputs.commit_hash }}
102- tag : v ${{ inputs.release }}
154+ allowUpdates : " true "
155+ artifacts : " release-*-*/*.tar.gz "
156+ bodyFile : release_notes/ ${{ env.FABRIC_VER }}.md
157+ tag : ${{ env.FABRIC_VER }}
103158 token : ${{ secrets.GITHUB_TOKEN }}
0 commit comments