Skip to content

Commit 419d701

Browse files
authored
chore: parallel builds with Makefile (coder#3854)
* Revert "revert: Makefile buff-ification (coder#3700) (coder#3848)" This reverts commit e490bdd. * fix: fix slim targets in makefile * fix: don't clobber slim binaries, make sure they're in the correct location
1 parent 4f0105e commit 419d701

18 files changed

+534
-720
lines changed

.github/workflows/coder.yaml

+8-25
Original file line numberDiff line numberDiff line change
@@ -500,35 +500,21 @@ jobs:
500500
- name: Install zstd
501501
run: sudo apt-get install -y zstd
502502

503-
- name: Build site
504-
run: make -B site/out/index.html
505-
506503
- name: Build Release
507504
run: |
508505
set -euo pipefail
509506
go mod download
510507
511-
mkdir -p ./dist
512-
# build slim binaries
513-
./scripts/build_go_slim.sh \
514-
--output ./dist/ \
515-
--compress 22 \
516-
linux:amd64,armv7,arm64 \
517-
windows:amd64,arm64 \
518-
darwin:amd64,arm64
519-
520-
# build linux amd64 packages
521-
./scripts/build_go_matrix.sh \
522-
--output ./dist/ \
523-
--package-linux \
524-
linux:amd64 \
525-
windows:amd64
508+
version="$(./scripts/version.sh)"
509+
make -j \
510+
build/coder_"$version"_windows_amd64.zip \
511+
build/coder_"$version"_linux_amd64.{tar.gz,deb}
526512
527513
- name: Install Release
528514
run: |
529515
gcloud config set project coder-dogfood
530516
gcloud config set compute/zone us-central1-a
531-
gcloud compute scp ./dist/coder_*_linux_amd64.deb coder:/tmp/coder.deb
517+
gcloud compute scp ./build/coder_*_linux_amd64.deb coder:/tmp/coder.deb
532518
gcloud compute ssh coder -- sudo dpkg -i --force-confdef /tmp/coder.deb
533519
gcloud compute ssh coder -- sudo systemctl daemon-reload
534520
@@ -539,12 +525,9 @@ jobs:
539525
with:
540526
name: coder
541527
path: |
542-
./dist/*.zip
543-
./dist/*.exe
544-
./dist/*.tar.gz
545-
./dist/*.apk
546-
./dist/*.deb
547-
./dist/*.rpm
528+
./build/*.zip
529+
./build/*.tar.gz
530+
./build/*.deb
548531
retention-days: 7
549532

550533
test-js:

.github/workflows/release.yaml

+28-55
Original file line numberDiff line numberDiff line change
@@ -71,46 +71,28 @@ jobs:
7171
- name: Install zstd
7272
run: sudo apt-get install -y zstd
7373

74-
- name: Build Site
75-
run: make site/out/index.html
76-
7774
- name: Build Linux and Windows Binaries
7875
run: |
7976
set -euo pipefail
8077
go mod download
8178
82-
mkdir -p ./dist
83-
# build slim binaries
84-
./scripts/build_go_slim.sh \
85-
--output ./dist/ \
86-
--compress 22 \
87-
linux:amd64,armv7,arm64 \
88-
windows:amd64,arm64 \
89-
darwin:amd64,arm64
90-
91-
# build linux and windows binaries
92-
./scripts/build_go_matrix.sh \
93-
--output ./dist/ \
94-
--archive \
95-
--package-linux \
96-
linux:amd64,armv7,arm64 \
97-
windows:amd64,arm64
79+
version="$(./scripts/version.sh)"
80+
make -j \
81+
build/coder_"$version"_linux_{amd64,armv7,arm64}.{tar.gz,apk,deb,rpm} \
82+
build/coder_"$version"_windows_{amd64,arm64}.zip \
9883
9984
- name: Build Linux Docker images
10085
run: |
10186
set -euxo pipefail
10287
10388
# build and (maybe) push Docker images for each architecture
104-
images=()
105-
for arch in amd64 armv7 arm64; do
106-
img="$(
107-
./scripts/build_docker.sh \
108-
${{ (!github.event.inputs.dry_run && !github.event.inputs.snapshot) && '--push' || '' }} \
109-
--arch "$arch" \
110-
./dist/coder_*_linux_"$arch"
111-
)"
112-
images+=("$img")
113-
done
89+
version="$(./scripts/version.sh)"
90+
push=""
91+
if [[ "$CODER_RELEASE" == *t* ]]; then
92+
push="push/"
93+
fi
94+
make -j \
95+
"$push"build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
11496
11597
# we can't build multi-arch if the images aren't pushed, so quit now
11698
# if dry-running
@@ -120,14 +102,13 @@ jobs:
120102
fi
121103
122104
# build and push multi-arch manifest
123-
./scripts/build_docker_multiarch.sh \
124-
--push \
125-
"${images[@]}"
105+
make -j push/build/coder_"$version"_linux.tag
126106
127107
# if the current version is equal to the highest (according to semver)
128108
# version in the repo, also create a multi-arch image as ":latest" and
129109
# push it
130110
if [[ "$(git tag | grep '^v' | grep -vE '(rc|dev|-|\+|\/)' | sort -r --version-sort | head -n1)" == "v$(./scripts/version.sh)" ]]; then
111+
make -j push/build/coder_"$version"_linux.tag
131112
./scripts/build_docker_multiarch.sh \
132113
--push \
133114
--target "$(./scripts/image_tag.sh --version latest)" \
@@ -139,11 +120,11 @@ jobs:
139120
with:
140121
name: linux
141122
path: |
142-
dist/*.zip
143-
dist/*.tar.gz
144-
dist/*.apk
145-
dist/*.deb
146-
dist/*.rpm
123+
./build/*.zip
124+
./build/*.tar.gz
125+
./build/*.apk
126+
./build/*.deb
127+
./build/*.rpm
147128
148129
# The mac binaries get built on mac runners because they need to be signed,
149130
# and the signing tool only runs on mac. This darwin job only builds the Mac
@@ -213,22 +194,11 @@ jobs:
213194
set -euo pipefail
214195
go mod download
215196
216-
mkdir -p ./dist
217-
# build slim binaries
218-
./scripts/build_go_slim.sh \
219-
--output ./dist/ \
220-
--compress 22 \
221-
linux:amd64,armv7,arm64 \
222-
windows:amd64,arm64 \
223-
darwin:amd64,arm64
224-
225-
# build darwin binaries
226-
./scripts/build_go_matrix.sh \
227-
--output ./dist/ \
228-
--archive \
229-
--sign-darwin \
230-
darwin:amd64,arm64
197+
version="$(./scripts/version.sh)"
198+
make -j \
199+
build/coder_"$version"_darwin_{amd64,arm64}.zip
231200
env:
201+
CODER_SIGN_DARWIN: "1"
232202
AC_USERNAME: ${{ secrets.AC_USERNAME }}
233203
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
234204
AC_APPLICATION_IDENTITY: BDB050EB749EDD6A80C6F119BF1382ECA119CCCC
@@ -237,7 +207,7 @@ jobs:
237207
uses: actions/upload-artifact@v3
238208
with:
239209
name: darwin
240-
path: ./dist/coder_*.zip
210+
path: ./build/*.zip
241211

242212
publish:
243213
runs-on: ubuntu-latest
@@ -278,8 +248,11 @@ jobs:
278248
- name: Publish Helm
279249
run: |
280250
set -euxo pipefail
281-
./scripts/helm.sh --push
282-
mv ./dist/*.tgz ./artifacts/
251+
252+
version="$(./scripts/version.sh)"
253+
make -j \
254+
build/coder_helm_"$version".tgz
255+
mv ./build/*.tgz ./artifacts/
283256
284257
- name: Publish Release
285258
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ site/**/*.typegen.ts
3030
site/build-storybook.log
3131

3232
# Build
33+
build/
3334
dist/
3435
site/out/
3536

0 commit comments

Comments
 (0)