This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
263 lines (249 loc) · 10.2 KB
/
build.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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
name: build
on:
workflow_dispatch:
push:
branches:
- main
- release/*
env:
METADATA: "oss"
PKG_NAME: "waypoint"
permissions:
contents: read
statuses: write
packages: write
jobs:
get-product-version:
name: "Determine intended Waypoint version"
runs-on: ubuntu-latest
outputs:
product-version: ${{ steps.get-product-version.outputs.product-version }}
base-product-version: ${{ steps.get-product-version.outputs.base-product-version }}
prerelease-product-version: ${{ steps.get-product-version.outputs.prerelease-product-version }}
pkg-name: ${{ steps.get-pkg-env-vars.outputs.pkg-name }}
pkg-metadata: ${{ steps.get-pkg-env-vars.outputs.pkg-metadata }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Get package environment variables
id: get-pkg-env-vars
run: |
pkg_name=${{ env.PKG_NAME }}
pkg_metadata=${{ env.METADATA }}
echo "pkg-metadata=${pkg_metadata}" | tee -a "${GITHUB_OUTPUT}"
echo "pkg-name=${pkg_name}" | tee -a "${GITHUB_OUTPUT}"
- name: Decide version number
id: get-product-version
uses: hashicorp/actions-set-product-version@v1
- name: Report chosen version number
run: |
[ -n "${{steps.get-product-version.outputs.product-version}}" ]
echo "::notice title=Waypoint Version::${{ steps.get-product-version.outputs.product-version }}"
get-go-version:
name: "Determine Go toolchain version"
runs-on: ubuntu-latest
outputs:
go-version: ${{ steps.get-go-version.outputs.go-version }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Determine Go version
id: get-go-version
run: |
echo "Building with Go $(cat .go-version)"
echo "go-version=$(cat .go-version)" >> "$GITHUB_OUTPUT"
generate-metadata-file:
name: "Generate release metadata"
runs-on: ubuntu-latest
needs: get-product-version
outputs:
filepath: ${{ steps.generate-metadata-file.outputs.filepath }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Generate package metadata
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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: metadata.json
path: ${{ steps.generate-metadata-file.outputs.filepath }}
build-ui:
runs-on: ubuntu-latest
name: Build UI
needs: get-product-version
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Set up node and yarn
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 14
cache: yarn
cache-dependency-path: ui/yarn.lock
- name: Build UI
run: |
export PKG_VERSION=${{ needs.get-product-version.outputs.product-version }}
export PKG_BINARY_TYPE=${{ needs.get-product-version.outputs.pkg-metadata }}
PKG_COPYRIGHT_YEAR="$(git show -s --format=%cd --date=format:%Y HEAD)" ; export PKG_COPYRIGHT_YEAR
export PKG_NAME=${{ needs.get-product-version.outputs.pkg-name }}
echo "${PKG_NAME} version is ${PKG_VERSION}"
echo "${PKG_NAME} binary type is ${PKG_BINARY_TYPE}"
echo "${PKG_NAME} copyright year is ${PKG_COPYRIGHT_YEAR}"
cd ui && make && cd ..
- name: Save assets to cache
uses: actions/cache/save@v3 # TSCCR: no version of actions/cache trusts nested action "save"
with:
path: ui/dist/assets
key: ui_assets_${{ github.sha }}
build-assets:
runs-on: ubuntu-latest
name: Build Assets
needs:
- get-go-version
- get-product-version
- build-ui
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9 # v4.0.0
with:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- name: Restore ui assets
uses: actions/cache/restore@v3 # TSCCR: no version of actions/cache trusts nested action "restore"
with:
path: ui/dist/assets
key: ui_assets_${{ github.sha }}
fail-on-cache-miss: true
enableCrossOsArchive: true
- name: Build assets
env:
BASE_VERSION: ${{ needs.get-product-version.outputs.base-product-version }}
PRERELEASE: ${{ needs.get-product-version.outputs.prerelease-product-version }}
run: |
make tools
go install github.com/kevinburke/go-bindata/[email protected]+incompatible
make bin/crt-assets
- name: Save assets to cache
uses: actions/cache/save@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: internal/assets
key: build_assets_${{ github.sha }}
build-waypoint:
needs:
- get-product-version
- get-go-version
- build-assets
- build-ui
strategy:
matrix:
pkg-name: [ "waypoint", "waypoint-entrypoint" ]
goos: [ linux ]
goarch: [ "386", "amd64", "arm", "arm64" ]
include:
- {goos: "windows", goarch: "386", pkg-name: "waypoint" }
- {goos: "windows", goarch: "amd64", pkg-name: "waypoint"}
- {goos: "darwin", goarch: "arm64", pkg-name: "waypoint"}
- {goos: "darwin", goarch: "amd64", pkg-name: "waypoint"}
- { goos: "darwin", goarch: "arm64", pkg-name: "waypoint-entrypoint" }
- { goos: "darwin", goarch: "amd64", pkg-name: "waypoint-entrypoint" }
name: Go ${{ matrix.goos }} ${{ matrix.goarch }} build
uses: ./.github/workflows/build-waypoint-oss.yml
with:
create-packages: false
goarch: ${{ matrix.goarch }}
goos: ${{ matrix.goos }}
go-tags: ui
go-version: ${{ needs.get-go-version.outputs.go-version }}
package-name: ${{ matrix.pkg-name }}
waypoint-version: ${{ needs.get-product-version.outputs.product-version }}
waypoint-base-version: ${{ needs.get-product-version.outputs.base-product-version }}
waypoint-prerelease: ${{ needs.get-product-version.outputs.prerelease-product-version }}
secrets: inherit
package-docker-waypoint-server:
name: Build Docker Server image for linux_${{ matrix.arch }}
runs-on: ubuntu-latest
needs:
- get-product-version
- build-waypoint
strategy:
matrix:
arch: [ "amd64", "arm64" ]
fail-fast: false
env:
repo: "waypoint"
version: ${{ needs.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Download Waypoint
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: archive
name: waypoint_${{env.version}}_linux_${{ matrix.arch }}.zip
- name: Download Entrypoint
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
path: archive
name: waypoint-entrypoint_${{ env.version }}_linux_${{ matrix.arch }}.zip
- name: Prepare zipped binaries to build Docker image
id: prepare-zips
run: |
DIR="$(mktemp -d)"
echo "working-dir=$DIR" >> "$GITHUB_OUTPUT"
cp -v CRT.Dockerfile "$DIR/CRT.Dockerfile"
unzip -j "archive/waypoint_${{env.version}}_linux_${{ matrix.arch }}.zip" -d "$DIR"
unzip -j "archive/waypoint-entrypoint_${{env.version}}_linux_${{ matrix.arch }}.zip" -d "$DIR"
- name: Build Docker image
uses: hashicorp/actions-docker-build@v1
with:
pkg_name: "waypoint_${{env.version}}"
dockerfile: CRT.Dockerfile
version: ${{ env.version }}
bin_name: ${{ env.repo }}
do_zip_extract_step: false
workdir: ${{ steps.prepare-zips.outputs.working-dir }}
target: crt
arch: ${{matrix.arch}}
smoke_test: .github/scripts/verify_docker.sh ${{ needs.get-product-version.outputs.product-version }}
tags: |
docker.io/hashicorp/${{env.repo}}:${{env.version}}
public.ecr.aws/hashicorp/${{env.repo}}:${{env.version}}
package-docker-waypoint-odr:
name: Build Docker ODR image for linux_${{ matrix.arch }}
runs-on: ubuntu-latest
needs:
- get-product-version
- build-waypoint
strategy:
matrix:
arch: [ "amd64", "arm64" ]
fail-fast: false
env:
repo: "waypoint"
version: ${{ needs.get-product-version.outputs.product-version }}
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Build Docker image
uses: hashicorp/actions-docker-build@v1
with:
pkg_name: "waypoint_${{env.version}}"
dockerfile: CRT.Dockerfile
version: ${{ env.version }}
bin_name: ${{ env.repo }}
target: odr-crt
arch: ${{matrix.arch}}
smoke_test: .github/scripts/verify_docker.sh ${{ needs.get-product-version.outputs.product-version }}
tags: |
docker.io/hashicorp/${{env.repo}}-odr:${{env.version}}
public.ecr.aws/hashicorp/${{env.repo}}-odr:${{env.version}}
end-to-end-tests:
needs:
- get-product-version
- package-docker-waypoint-server
- package-docker-waypoint-odr
uses: ./.github/workflows/end-to-end.yml
with:
waypoint-binary: waypoint_${{needs.get-product-version.outputs.product-version}}_linux_amd64.zip
waypoint-tar: waypoint_crt_linux_amd64_${{needs.get-product-version.outputs.product-version}}_${{github.sha}}.docker.tar
waypoint-image: hashicorp/waypoint:${{ needs.get-product-version.outputs.product-version }}
waypoint-odr-tar: waypoint_odr-crt_linux_amd64_${{needs.get-product-version.outputs.product-version}}_${{github.sha}}.docker.tar
waypoint-odr-image: hashicorp/waypoint-odr:${{ needs.get-product-version.outputs.product-version }}
secrets: inherit