-
Notifications
You must be signed in to change notification settings - Fork 60
149 lines (135 loc) · 5.02 KB
/
build.yml
File metadata and controls
149 lines (135 loc) · 5.02 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: build
on:
push:
workflow_dispatch:
inputs:
version:
description: "Version to build, e.g. 0.1.0"
type: string
required: false
env:
PKG_NAME: "vault-csi-provider"
jobs:
get-product-version:
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: get product version
id: get-product-version
run: |
VERSION="${{ github.event.inputs.version || format('0.0.0-dev+{0}', github.sha) }}"
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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Generate metadata file
id: generate-metadata-file
uses: hashicorp/actions-generate-metadata@v1
with:
version: ${{ needs.get-product-version.outputs.product-version }}
product: ${{ env.PKG_NAME }}
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.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", "s390x"]
fail-fast: true
name: Go linux ${{ matrix.arch }} build
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: .go-version
- name: Build
id: build-binary
env:
GOOS: "linux"
GOARCH: ${{ matrix.arch }}
VERSION: ${{ needs.get-product-version.outputs.product-version }}
shell: bash
run: |
BUILD_DIR=dist
make build BUILD_DIR="${BUILD_DIR}"
OUT_DIR='build/out'
mkdir -p "${OUT_DIR}"
cp -a LICENSE "${BUILD_DIR}/LICENSE.txt"
ZIP_FILE="${OUT_DIR}/${{ env.PKG_NAME }}_${{ needs.get-product-version.outputs.product-version }}_linux_${{ matrix.arch }}.zip"
zip -r -j "${ZIP_FILE}" "${BUILD_DIR}/"
echo "path=${ZIP_FILE}" >> $GITHUB_OUTPUT
echo "name=$(basename ${ZIP_FILE})" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
with:
name: ${{ steps.build-binary.outputs.name }}
path: ${{ steps.build-binary.outputs.path }}
build-docker:
name: Docker alpine ${{ matrix.arch }} build
needs:
- get-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["arm", "arm64", "386", "amd64"]
env:
repo: ${{github.event.repository.name}}
version: ${{needs.get-product-version.outputs.product-version}}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Docker Build (Action)
uses: hashicorp/actions-docker-build@v2
with:
version: ${{env.version}}
target: default
arch: ${{matrix.arch}}
tags: |
docker.io/hashicorp/${{env.repo}}:${{env.version}}
public.ecr.aws/hashicorp/${{env.repo}}:${{env.version}}
build-ubi:
name: Docker UBI ${{ matrix.arch }} build
needs:
- get-product-version
- build
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["arm64", "amd64", "s390x"]
env:
repo: ${{github.event.repository.name}}
version: ${{needs.get-product-version.outputs.product-version}}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Docker Build (Action) ${{ matrix.arch }}
# linux/s390x images can only ever be published the Red Hat catalog. In the future they may be pushed to ICR as well.
if: ${{ matrix.arch != 's390x'}}
uses: hashicorp/actions-docker-build@v2
with:
version: ${{env.version}}
target: release-ubi
arch: ${{matrix.arch}}
redhat_tag: quay.io/redhat-isv-containers/68961b49ae4b51ff35f52b77:${{env.version}}-ubi
tags: |
docker.io/hashicorp/${{env.repo}}:${{env.version}}-ubi
- name: Docker Build (Action) ${{ matrix.arch }}
# linux/s390x images can only ever be published the Red Hat catalog. In the future they may be pushed to ICR as well.
if: ${{ matrix.arch == 's390x'}}
uses: hashicorp/actions-docker-build@v2
with:
version: ${{env.version}}
target: release-ubi
arch: ${{matrix.arch}}
redhat_tag: quay.io/redhat-isv-containers/68961b49ae4b51ff35f52b77:${{env.version}}-ubi