Skip to content

Commit da9ed47

Browse files
authored
Release Tooling (#9)
1 parent 1dc4bee commit da9ed47

File tree

12 files changed

+724
-36
lines changed

12 files changed

+724
-36
lines changed

.github/workflows/build.yml

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
name: build
2+
3+
# We now default to running this workflow on every push to every branch.
4+
# This provides fast feedback when build issues occur, so they can be
5+
# fixed prior to being merged to the main branch.
6+
#
7+
# If you want to opt out of this, and only run the build on certain branches
8+
# please refer to the documentation on branch filtering here:
9+
#
10+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore
11+
#
12+
on: [workflow_dispatch, push]
13+
14+
env:
15+
PKG_NAME: "consul-dataplane"
16+
17+
jobs:
18+
get-go-version:
19+
name: "Determine Go toolchain version"
20+
runs-on: ubuntu-latest
21+
outputs:
22+
go-version: ${{ steps.get-go-version.outputs.go-version }}
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Determine Go version
26+
id: get-go-version
27+
# We use .go-version as our source of truth for current Go
28+
# version, because "goenv" can react to it automatically.
29+
run: |
30+
echo "Building with Go $(cat .go-version)"
31+
echo "::set-output name=go-version::$(cat .go-version)"
32+
33+
get-product-version:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
product-version: ${{ steps.get-product-version.outputs.product-version }}
37+
steps:
38+
- uses: actions/checkout@v2
39+
- name: get product version
40+
id: get-product-version
41+
run: |
42+
make version
43+
echo "::set-output name=product-version::$(make version)"
44+
45+
generate-metadata-file:
46+
needs: get-product-version
47+
runs-on: ubuntu-latest
48+
outputs:
49+
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
50+
steps:
51+
- name: "Checkout directory"
52+
uses: actions/checkout@v2
53+
- name: Generate metadata file
54+
id: generate-metadata-file
55+
uses: hashicorp/actions-generate-metadata@v1
56+
with:
57+
version: ${{ needs.get-product-version.outputs.product-version }}
58+
product: ${{ env.PKG_NAME }}
59+
repositoryOwner: "hashicorp"
60+
- uses: actions/upload-artifact@v2
61+
with:
62+
name: metadata.json
63+
path: ${{ steps.generate-metadata-file.outputs.filepath }}
64+
65+
build-linux:
66+
needs:
67+
- get-go-version
68+
- get-product-version
69+
runs-on: ubuntu-latest
70+
strategy:
71+
matrix:
72+
goos: [linux]
73+
goarch: ["arm", "arm64", "386", "amd64"]
74+
75+
fail-fast: true
76+
77+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
78+
79+
steps:
80+
- uses: actions/checkout@v2
81+
82+
- uses: hashicorp/actions-go-build@v0
83+
with:
84+
product_name: ${{ env.PKG_NAME }}
85+
product_version: ${{ needs.get-product-version.outputs.product-version }}
86+
go_version: ${{ needs.get-go-version.outputs.go-version }}
87+
os: ${{ matrix.goos }}
88+
arch: ${{ matrix.goarch }}
89+
reproducible: assert
90+
instructions: CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME
91+
92+
- name: Package
93+
if: ${{ matrix.goos == 'linux' }}
94+
uses: hashicorp/actions-packaging-linux@v1
95+
with:
96+
name: ${{ github.event.repository.name }}
97+
description: "Consul dataplane connects an application to a Consul service mesh."
98+
arch: ${{ matrix.goarch }}
99+
version: ${{ needs.get-product-version.outputs.product-version }}
100+
maintainer: "HashiCorp"
101+
homepage: "https://github.com/hashicorp/consul-dataplane"
102+
license: "MPL-2.0"
103+
binary: "dist/${{ env.PKG_NAME }}"
104+
deb_depends: "openssl"
105+
rpm_depends: "openssl"
106+
107+
- name: Set Package Names
108+
if: ${{ matrix.goos == 'linux' }}
109+
run: |
110+
echo "RPM_PACKAGE=$(basename out/*.rpm)" >> $GITHUB_ENV
111+
echo "DEB_PACKAGE=$(basename out/*.deb)" >> $GITHUB_ENV
112+
113+
- uses: actions/upload-artifact@v2
114+
if: ${{ matrix.goos == 'linux' }}
115+
with:
116+
name: ${{ env.RPM_PACKAGE }}
117+
path: out/${{ env.RPM_PACKAGE }}
118+
119+
- uses: actions/upload-artifact@v2
120+
if: ${{ matrix.goos == 'linux' }}
121+
with:
122+
name: ${{ env.DEB_PACKAGE }}
123+
path: out/${{ env.DEB_PACKAGE }}
124+
125+
build-darwin:
126+
needs:
127+
- get-go-version
128+
- get-product-version
129+
runs-on: macos-latest
130+
strategy:
131+
matrix:
132+
goos: [darwin]
133+
goarch: ["amd64", "arm64"]
134+
fail-fast: true
135+
136+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
137+
138+
env:
139+
GOOS: ${{ matrix.goos }}
140+
GOARCH: ${{ matrix.goarch }}
141+
142+
steps:
143+
- uses: actions/checkout@v2
144+
145+
- uses: hashicorp/actions-go-build@v0
146+
with:
147+
product_name: ${{ env.PKG_NAME }}
148+
product_version: ${{ needs.get-product-version.outputs.product-version }}
149+
go_version: ${{ needs.get-go-version.outputs.go-version }}
150+
os: ${{ matrix.goos }}
151+
arch: ${{ matrix.goarch }}
152+
reproducible: assert
153+
instructions: CGO_ENABLED=0 go build -trimpath -buildvcs=false -ldflags="-X github.com/hashicorp/consul-dataplane/pkg/version.GitCommit=${GITHUB_SHA::8}" -o $BIN_PATH ./cmd/$BIN_NAME
154+
155+
build-docker-default:
156+
name: Docker ${{ matrix.arch }} default release build
157+
needs:
158+
- get-product-version
159+
- build-linux
160+
runs-on: ubuntu-latest
161+
strategy:
162+
matrix:
163+
# This is the subset of architectures we build binaries for officially
164+
# supported by Envoy.
165+
arch: ["arm64", "amd64"]
166+
env:
167+
repo: ${{ github.event.repository.name }}
168+
version: ${{ needs.get-product-version.outputs.product-version }}
169+
170+
steps:
171+
- uses: actions/checkout@v2
172+
173+
# Strip everything but MAJOR.MINOR from the version string and add a `-dev` suffix
174+
# This naming convention will be used ONLY for per-commit dev images
175+
- name: Set docker dev tag
176+
run: |
177+
version="${{ env.version }}"
178+
echo "dev_tag=${version%.*}-dev" >> $GITHUB_ENV
179+
180+
- name: Docker Build (Action)
181+
uses: hashicorp/actions-docker-build@v1
182+
with:
183+
smoke_test: |
184+
TEST_VERSION="$(docker run "${IMAGE_NAME}" --version | head -n1 | cut -d' ' -f3 | sed 's/^v//')"
185+
if [ "${TEST_VERSION}" != "${version}" ]; then
186+
echo "Test FAILED"
187+
exit 1
188+
fi
189+
echo "Test PASSED"
190+
version: ${{ env.version }}
191+
target: release-default
192+
arch: ${{ matrix.arch }}
193+
tags: |
194+
docker.io/hashicorp/${{env.repo}}:${{env.version}}
195+
public.ecr.aws/hashicorp/${{env.repo}}:${{env.version}}
196+
dev_tags: |
197+
docker.io/hashicorppreview/${{ env.repo }}:${{ env.dev_tag }}
198+
docker.io/hashicorppreview/${{ env.repo }}:${{ env.dev_tag }}-${{ github.sha }}
199+
200+
build-docker-redhat:
201+
name: Docker UBI Image Build (for Red Hat Certified Container Registry)
202+
needs:
203+
- get-product-version
204+
- build-linux
205+
runs-on: ubuntu-latest
206+
env:
207+
repo: ${{github.event.repository.name}}
208+
version: ${{needs.get-product-version.outputs.product-version}}
209+
210+
steps:
211+
- uses: actions/checkout@v2
212+
- uses: hashicorp/actions-docker-build@v1
213+
with:
214+
version: ${{env.version}}
215+
target: release-ubi
216+
arch: amd64
217+
redhat_tag: scan.connect.redhat.com/ospid-62211e0d8bf2cabc69a39c7d/${{env.repo}}:${{env.version}}-ubi

.go-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.19.1

0 commit comments

Comments
 (0)