Skip to content

Commit

Permalink
GHA Workflows (#131)
Browse files Browse the repository at this point in the history
Publish the docker image and binary to a release

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
  • Loading branch information
mbwhite committed Jan 12, 2023
1 parent 9092c08 commit 05f8cff
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 102 deletions.
53 changes: 0 additions & 53 deletions .github/workflows/container.yml

This file was deleted.

125 changes: 76 additions & 49 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,14 @@ on:
- cron: "0 0 * * *"
create:
tags:
- "*"
- "v*"
workflow_dispatch: {}

jobs:
binary_build:
name: Binary Build
runs-on: ubuntu-latest
strategy:
matrix:
goarch: [amd64, arm64]
env:
GOARCH: ${{ matrix.goarch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build Binary
run: go build -v -o bin/microfabd cmd/microfabd/main.go
- name: Package Binary
run: |
export GOOS=$(go env GOOS)
tar -C bin -czvf microfab-${GOOS}-${GOARCH}.tgz microfabd
- name: Publish Binary to GitHub Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: microfab-*.tgz
docker_build:
name: Docker Build

# Lint, Compile and Core Function Tests
build:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -82,26 +59,76 @@ jobs:
make integration
- name: Run ShellCheck
run: shellcheck $(ls builders/*/bin/* -1 | grep -v ccaas)
- name: Build Docker image
run: |
docker build -t ibmcom/ibp-microfab:latest .
- name: Setup the Fabric Binaries
run: |
npm install -g @hyperledger-labs/weft
- name: Run container tests
run: |
export PATH="/opt/fabric/bin:${PATH}"
export FABRIC_CFG_PATH=/opt/fabric/config

./scripts/test-container.sh
- name: Publish Docker image to Docker Hub
env:
DOCKER_HUB_USER_NAME: ${{ secrets.DOCKER_HUB_USER_NAME }}
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Build the daemon binary and if a release publish if a 'tag' build
# amd64/arm64
binary_build:
name: Binary Build
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
goarch: [amd64, arm64]
env:
GOARCH: ${{ matrix.goarch }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Go 1.17
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Build Binary
run: go build -v -o bin/microfabd cmd/microfabd/main.go
- name: Package Binary
run: |
VERSION=$(echo ${GITHUB_REF#refs/tags/} | sed 's/^v//')
docker tag ibmcom/ibp-microfab:latest ibmcom/ibp-microfab:${VERSION}
docker login -u ${DOCKER_HUB_USER_NAME} -p ${DOCKER_HUB_ACCESS_TOKEN}
docker push ibmcom/ibp-microfab:${VERSION}
docker push ibmcom/ibp-microfab:latest
export GOOS=$(go env GOOS)
tar -C bin -czvf microfab-${GOOS}-${GOARCH}.tgz microfabd
- name: Publish Binary to GitHub Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: microfab-*.tgz

# Build the container images and push to the ghcr.io repo
# amd64/arm64
container_build:
runs-on: ubuntu-latest
needs: build
outputs:
image_digest: ${{ steps.push.outputs.digest }}

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
ghcr.io/hyperledger-labs/microfab
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile2
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# NOTE THIS DOCKERFILE IS CONSIDERED DEPRECATED
FROM registry.access.redhat.com/ubi8/ubi-minimal AS base
ADD docker/couchdb-rpm.repo /etc/yum.repos.d/couchdb-rpm.repo
RUN microdnf install couchdb findutils gcc gcc-c++ git gzip make python3 shadow-utils tar unzip xz \
Expand Down

0 comments on commit 05f8cff

Please sign in to comment.