Skip to content

Commit

Permalink
Merge pull request #857 from carvel-dev/build-binaries-in44.x
Browse files Browse the repository at this point in the history
build-binaries only builds final binary files
  • Loading branch information
kumaritanushree committed Jun 19, 2023
2 parents 8540341 + add0167 commit 3e58fe5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Make sure to check the documentation at http://goreleaser.com
before:
hooks:
- go mod tidy
- ./hack/generate-website-assets.sh
builds:
- env:
- CGO_ENABLED=0
Expand Down
4 changes: 2 additions & 2 deletions hack/build-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ function get_latest_git_tag {
git describe --tags | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
}

VERSION="${1:-`get_latest_git_tag`}"
VERSION="${1:-$(get_latest_git_tag)}"

# makes builds reproducible
export CGO_ENABLED=0
LDFLAGS="-X github.com/vmware-tanzu/carvel-ytt/pkg/version.Version=$VERSION"

./hack/build.sh $VERSION # Used to generate website/generated.go used by ytt website
./hack/generate-website-assets.sh

GOOS=darwin GOARCH=amd64 go build -ldflags="$LDFLAGS" -trimpath -o ytt-darwin-amd64 ./cmd/ytt
GOOS=darwin GOARCH=arm64 go build -ldflags="$LDFLAGS" -trimpath -o ytt-darwin-arm64 ./cmd/ytt
Expand Down
21 changes: 1 addition & 20 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,9 @@ go mod vendor
go mod tidy

# build without website assets
rm -f pkg/website/generated.go
go build -ldflags="$LDFLAGS" -trimpath -o ytt ./cmd/ytt/...
./ytt version

(
# Use newly built binary to template all website assets
# into a single Go file
cd pkg/website
./../../ytt \
-f . \
-f ../../examples/playground/basics \
-f ../../examples/playground/overlays \
-f ../../examples/playground/getting-started \
--file-mark 'alt-example**/*:type=data' \
--file-mark 'example**/*:type=data' \
--file-mark 'generated.go.txt:exclusive-for-output=true' \
--dangerous-emptied-output-directory ../../tmp/
)
mv tmp/generated.go.txt pkg/website/generated.go
./hack/generate-website-assets.sh

# rebuild with website assets
rm -f ./ytt
go build -ldflags="$LDFLAGS" -trimpath -o ytt ./cmd/ytt/...
./ytt version

Expand Down
21 changes: 21 additions & 0 deletions hack/generate-website-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -e -x -u

# build website assets
rm -f pkg/website/generated.go
(
# Use newly built binary to template all website assets
# into a single Go file
cd pkg/website
go run ./../../cmd/ytt \
-f . \
-f ../../examples/playground/basics \
-f ../../examples/playground/overlays \
-f ../../examples/playground/getting-started \
--file-mark 'alt-example**/*:type=data' \
--file-mark 'example**/*:type=data' \
--file-mark 'generated.go.txt:exclusive-for-output=true' \
--dangerous-emptied-output-directory ../../tmp/
)
mv tmp/generated.go.txt pkg/website/generated.go

0 comments on commit 3e58fe5

Please sign in to comment.