Skip to content

Commit

Permalink
Merge pull request #824 from carvel-dev/remove-formating-on-release
Browse files Browse the repository at this point in the history
Do not run fmt and mod vendor when creating a release
  • Loading branch information
sethiyash committed May 4, 2023
2 parents 248ce34 + 071d358 commit 7440f7b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ jobs:
with:
go-version: "1.19.6"

- name: generate website/generate.go
if: startsWith(github.ref, 'refs/tags/')
- name: Retrieve version
run: |
./hack/build-binaries.sh "$VERSION"
echo "TAG_NAME=$(echo ${{ github.ref }} | grep -Eo 'v[0-9].*')" >> $GITHUB_OUTPUT
id: version

- name: Run GoReleaser
# GoReleaser v2.5.0
uses: goreleaser/goreleaser-action@5e15885530fb01d81d1f24e8a6f54ebbd0fed7eb
# GoReleaser v4.2.0
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b
if: startsWith(github.ref, 'refs/tags/')
with:
version: 0.181.1
args: release --rm-dist --debug
version: 1.16.2
args: release --rm-dist --debug ${{ env.SKIP_PUBLISH }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ steps.version.outputs.TAG_NAME }}

- uses: actions/github-script@v4
id: get-checksums-from-draft-release
Expand Down
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 7440f7b

Please sign in to comment.