forked from hyperledger-labs/microfab
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (103 loc) · 2.91 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# 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 }}