Publish Image #13
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
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# | |
--- | |
name: Publish Image | |
on: | |
create: | |
tags: | |
- "v*" | |
workflow_dispatch: {} | |
jobs: | |
# Build the daemon binary and if a release publish if a 'tag' build | |
# amd64/arm64 | |
binary_build: | |
name: Binary Daemon 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.18 | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- 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 | |
# Build the cli binary and if a release publish if a 'tag' build | |
# amd64/arm64 | |
binary_cli_build: | |
name: Binary CLI 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.18 | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- name: Build Binary | |
run: go build -v -o bin/microfab-${GOARCH} cmd/microfab/main.go | |
- name: Publish Binary to GitHub Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: bin/microfab-* | |
# Build the container images and push to the ghcr.io repo | |
# amd64/arm64 | |
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/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 }} |