-
Notifications
You must be signed in to change notification settings - Fork 10
132 lines (120 loc) · 4.53 KB
/
build.yml
File metadata and controls
132 lines (120 loc) · 4.53 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: build
on:
push:
pull_request:
workflow_dispatch:
inputs:
version:
description: "Version to build, e.g. 0.1.0"
type: string
required: false
env:
PKG_NAME: "openbao-k8s"
jobs:
get-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: get product version
id: get-product-version
run: |
VERSION="${{ github.event.inputs.version || '0.0.0-dev' }}"
echo "Using version ${VERSION}"
echo "product-version=${VERSION}" >> $GITHUB_OUTPUT
generate-metadata-file:
needs: get-product-version
runs-on: ubuntu-latest
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- name: 'Checkout directory'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@f1d852525201cb7bbbf031dd2e985fb4c22307fc # v1.1.3
with:
version: ${{ needs.get-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}
build:
needs:
- get-product-version
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["arm", "arm64", "386", "amd64"]
fail-fast: true
name: Go linux ${{ matrix.arch }} build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup go
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
with:
go-version-file: .go-version
- name: Build
env:
GOOS: "linux"
GOARCH: ${{ matrix.arch }}
VERSION: ${{ needs.get-product-version.outputs.product-version }}
run: |
mkdir dist out
make build
zip -r -j out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip dist/
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: ${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip
path: out/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip
build-docker:
name: Docker ${{ matrix.arch }} build
needs:
- get-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [arm, arm64, amd64]
env:
repo: ${{ github.event.repository.name }}
version: ${{ needs.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@200254326a30d7b747745592f8f4d226bbe4abe4 # v2.2.0
with:
version: ${{ env.version }}
target: default
arch: ${{ matrix.arch }}
zip_artifact_name: ${{ env.PKG_NAME }}_${{ env.version }}_linux_${{ matrix.arch }}.zip
tags: |
quay.io/openbao/${{ env.PKG_NAME }}:${{ env.version }}
ghcr.io/openbao/${{ env.PKG_NAME }}:${{ env.version }}
docker.io/openbao/${{ env.PKG_NAME }}:${{ env.version }}
build-ubi:
name: Docker ${{ matrix.arch }} Build UBI Image
needs:
- get-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: [arm64, amd64]
env:
repo: ${{ github.event.repository.name }}
version: ${{ needs.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: hashicorp/actions-docker-build@200254326a30d7b747745592f8f4d226bbe4abe4 # v2.2.0
with:
version: ${{ env.version }}
target: ubi
arch: ${{ matrix.arch }}
zip_artifact_name: ${{ env.PKG_NAME }}_${{ env.version }}_linux_${{ matrix.arch }}.zip
tags: |
quay.io/openbao/${{ env.PKG_NAME }}-ubi:${{ env.version }}
ghcr.io/openbao/${{ env.PKG_NAME }}-ubi:${{ env.version }}
docker.io/openbao/${{ env.PKG_NAME }}-ubi:${{ env.version }}