Add v3.* tags as a trigger to release job #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright the Hyperledger Fabric contributors. All rights reserved. | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
name: Release | |
on: | |
workflow_dispatch: # workflow_dispatch must be enabled in main branch to support release action on older release branches | |
push: | |
tags: | |
- v2.* | |
- v3.* | |
env: | |
GO_VER: 1.20.7 | |
UBUNTU_VER: 20.04 | |
FABRIC_VER: ${{ github.ref_name }} | |
DOCKER_REGISTRY: ${{ github.repository_owner == 'hyperledger' && 'docker.io' || 'ghcr.io' }} | |
permissions: | |
contents: read | |
jobs: | |
build-binaries: | |
name: Build Fabric Binaries | |
strategy: | |
matrix: | |
include: | |
- image: fabric-ubuntu-20.04 | |
target: linux | |
arch: amd64 | |
- image: fabric-ubuntu-20.04 | |
target: linux | |
arch: arm64 | |
- image: macos-11 | |
target: darwin | |
arch: amd64 | |
- image: macos-11 | |
target: darwin | |
arch: arm64 | |
- image: fabric-windows-latest | |
target: windows | |
arch: amd64 | |
runs-on: fabric-ubuntu-20.04 | |
steps: | |
- name: Install Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GO_VER }} | |
- name: Checkout Fabric Code | |
uses: actions/checkout@v3 | |
- name: Compile Binary and Create Tarball | |
run: ./ci/scripts/create_binary_package.sh | |
env: | |
TARGET: ${{ matrix.target }}-${{ matrix.arch }} | |
RELEASE: ${{ env.FABRIC_VER }} | |
- name: Publish Release Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
# <name> of the artifact must not collide between platform/arch builds | |
name: release-${{ matrix.target }}-${{ matrix.arch }} | |
# <path> of the artifact may include multiple files. | |
path: release/${{ matrix.target }}-${{ matrix.arch }}/*.tar.gz | |
build-and-push-docker-images: | |
name: Build and Push | |
runs-on: fabric-ubuntu-20.04 | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
include: | |
- COMPONENT: baseos | |
CONTEXT: images/baseos | |
- COMPONENT: ccenv | |
CONTEXT: images/ccenv | |
- COMPONENT: peer | |
CONTEXT: . | |
- COMPONENT: orderer | |
CONTEXT: . | |
- COMPONENT: tools | |
CONTEXT: . | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
with: | |
buildkitd-flags: --debug | |
config-inline: | | |
[worker.oci] | |
max-parallelism = 1 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to the ${{ env.DOCKER_REGISTRY }} Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_USERNAME || github.actor }} | |
password: ${{ env.DOCKER_REGISTRY == 'docker.io' && secrets.DOCKERHUB_TOKEN || secrets.GITHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository_owner }}/fabric-${{ matrix.COMPONENT }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
- name: Build and push ${{ matrix.COMPONENT }} Image | |
id: push | |
uses: docker/build-push-action@v3 | |
with: | |
context: ${{ matrix.CONTEXT }} | |
file: images/${{ matrix.COMPONENT }}/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: ${{ steps.meta.outputs.tags }} | |
push: ${{ github.event_name != 'pull_request' }} | |
labels: ${{ steps.meta.outputs.labels }} | |
build-args: | | |
FABRIC_VER=${{ env.FABRIC_VER }} | |
UBUNTU_VER=${{ env.UBUNTU_VER }} | |
GO_VER=${{ env.GO_VER }} | |
GO_TAGS= | |
create-release: | |
name: Create GitHub Release | |
needs: | |
- build-binaries | |
- build-and-push-docker-images | |
runs-on: fabric-ubuntu-20.04 | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout Fabric Code | |
uses: actions/checkout@v3 | |
- name: Download Artifacts | |
id: download | |
uses: actions/download-artifact@v3 | |
- name: Release Fabric Version | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: "true" | |
artifacts: "release-*-*/*.tar.gz" | |
bodyFile: release_notes/${{ env.FABRIC_VER }}.md | |
tag: ${{ env.FABRIC_VER }} | |
token: ${{ secrets.GITHUB_TOKEN }} |