Skip to content

Commit

Permalink
Fail release early if tag != makefile version
Browse files Browse the repository at this point in the history
  • Loading branch information
fheinecke committed Nov 12, 2024
1 parent ca91609 commit fe70a4c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/reusable-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get the name of the tool
working-directory: ${{ inputs.tool-directory }}
run: set -e; echo "TOOL_NAME=$(make tool-name)" >> "${GITHUB_ENV}"
run: set -e; echo "TOOL_NAME=$(make print-print-tool-name)" >> "${GITHUB_ENV}"
- name: Create event-specific values
id: setup
run: |
Expand All @@ -42,14 +42,21 @@ jobs:
if [[ "${VERSION}" == *-* ]]; then
echo "is-prerelease=true" >> "${GITHUB_OUTPUT}"
fi
# Verify that the tag version matches the tool version
MAKEFILE_VERSION="$(make print-version)"
if [[ "${MAKEFILE_VERSION}" != "${VERSION}" ]]; then
echo "Makefile version '${MAKEFILE_VERSION}' does not match tag '${VERSION}'" >*2
exit 1
fi
fi
# Build the binaries
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: '${{ inputs.tool-directory }}/go.mod'
cache-dependency-path: '${{ inputs.tool-directory }}/go.sum'
go-version-file: "${{ inputs.tool-directory }}/go.mod"
cache-dependency-path: "${{ inputs.tool-directory }}/go.sum"

- name: Build the project
working-directory: ${{ inputs.tool-directory }}
Expand Down Expand Up @@ -136,4 +143,3 @@ jobs:
gh release create --title "${TOOL_NAME} ${VERSION}" --verify-tag \
--generate-notes "${EXTRA_FLAGS[@]}" "${GITHUB_REF_NAME}" \
"${RELEASE_TARBALLS[@]}"
7 changes: 5 additions & 2 deletions tools/repo-release-tooling/tooling.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ BINARY_NAME := $(BINARY_NAME).exe
endif
DOCKERFILE_PATH ?= ../repo-release-tooling/Dockerfile

tool-name:
print-tool-name:
@echo "$(TOOL_NAME)"

print-version:
@echo "$(VERSION)"

lint:
@golangci-lint run ./... --out-format colored-line-number -vvv

Expand All @@ -39,4 +42,4 @@ clean:
@rm -rf build/
@docker image rm -f "$(TOOL_NAME):$(CONTAINER_VERSION)" 2> /dev/null > /dev/null

.PHONY: tool-name lint test binary tarball container-image clean
.PHONY: print-tool-name print-version lint test binary tarball container-image clean

0 comments on commit fe70a4c

Please sign in to comment.