Skip to content

Commit

Permalink
Hopefully fix the release artifact error (#69)
Browse files Browse the repository at this point in the history
* Refactor build process and clean up Makefile

Significant changes include:
- Moved the creation of release artifacts from GitHub workflow to GoReleaser hooks.
- Refactored the Makefile for better readability and maintainability. This includes changing directory commands, modifying how VERSION_TAG is generated, and updating how tests are run.
- Commented out lines in provider/pkg/%.man target have been replaced with a simple touch command.

* Whoops
  • Loading branch information
UnstoppableMango authored Jul 31, 2024
1 parent 1708d6e commit 3649cba
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ jobs:
go-version-file: provider/go.mod
cache-dependency-path: provider/go.sum

- name: Make release artifacts
run: make dist/{install.sh,baremetal-provisioner.service}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand Down
5 changes: 5 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
version: 2

before:
hooks:
- make dist/baremetal-provisioner.service
- make dist/install.sh

builds:
- id: resource
binary: pulumi-resource-baremetal
Expand Down
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SUPPORTED_SDKS := dotnet go nodejs python
PROTO_VERSION := v1alpha1
PROVIDER_PATH := provider
VERSION_PATH := ${PROVIDER_PATH}.Version
VERSION_TAG ?= $(shell cut -d'.' -f-3 <<<'${VERSION}')
VERSION_TAG ?= $(shell cut -d'.' -f-3 <<<'${VERSION}' | sed 's/+dirty//')

GOPATH := $(shell go env GOPATH)

Expand Down Expand Up @@ -52,10 +52,14 @@ remake::
provider:: bin/$(PROVIDER)

provider_debug::
(cd provider && go build -o $(WORKING_DIR)/bin/${PROVIDER} -gcflags="all=-N -l" -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER))
go -C ${PROVIDER_PATH} build \
-o $(WORKING_DIR)/bin/${PROVIDER} \
-gcflags="all=-N -l" \
-ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" \
$(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER)

test_provider:: provisioner .make/provisioner_docker_build
cd tests && go test -short -v -count=1 -cover -timeout 2h ./.
go -C tests test -short -v -count=1 -cover -timeout 2h ./.

provisioner:: bin/provisioner

Expand Down Expand Up @@ -182,18 +186,21 @@ dist/baremetal-provisioner.service: $(PROVIDER_PATH)/cmd/provisioner/baremetal-p
mkdir -p '${@D}' && cp '$<' '$@'

bin/$(PROVIDER):: $(GEN_SRC) $(MAN_SRC) $(PKG_SRC) provider/*go*
cd provider && go build -o $(WORKING_DIR)/$@ -ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" $(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER)
go -C provider build \
-o $(WORKING_DIR)/$@ \
-ldflags "-X ${PROJECT}/${VERSION_PATH}=${VERSION}" \
$(PROJECT)/${PROVIDER_PATH}/cmd/$(PROVIDER)

bin/provisioner:: $(GEN_SRC) provider/cmd/provisioner/*.go $(PKG_SRC)
cd provider && go build -o ${WORKING_DIR}/$@ $(PROJECT)/${PROVIDER_PATH}/cmd/provisioner
go -C provider build -o ${WORKING_DIR}/$@ $(PROJECT)/${PROVIDER_PATH}/cmd/provisioner

gen/go/%.pb.go gen/go/%_grpc.pb.go &: $(BUF_CONFIG) proto/%.proto
buf generate --clean --path proto/$*.proto

provider/pkg/%.man: provider/pkg/%.go
# man $(notdir $*) > $@
# This is a terrible idea when the output depends on the terminal size
touch $@
@# man $(notdir $*) > $@
@# This is a terrible idea when the output depends on the terminal size
@touch $@

buf.lock: $(BUF_CONFIG)
buf dep update
Expand Down

0 comments on commit 3649cba

Please sign in to comment.