From 05f8cff33d63b54704f8fd46ff0de37addef7f9e Mon Sep 17 00:00:00 2001 From: Matthew B White Date: Thu, 12 Jan 2023 10:54:46 +0000 Subject: [PATCH] GHA Workflows (#131) Publish the docker image and binary to a release Signed-off-by: Matthew B White Signed-off-by: Matthew B White --- .github/workflows/container.yml | 53 -------------- .github/workflows/main.yml | 125 +++++++++++++++++++------------- Dockerfile | 1 + 3 files changed, 77 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/container.yml diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml deleted file mode 100644 index 96100db..0000000 --- a/.github/workflows/container.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Container Build - -on: - push: - tags: [ v* ] - branches: [ main ] - pull_request: - branches: [ main ] - workflow_dispatch: {} - -jobs: - - container_build: - runs-on: ubuntu-latest - - 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/ibm-blockchain/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 - #platforms: linux/amd64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c5c86f6..2ffd432 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 }} diff --git a/Dockerfile b/Dockerfile index 59a34b2..d01e1de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \