WIP: Working on the "release" target in Makefile
This commit is contained in:
		
							parent
							
								
									308fe5666b
								
							
						
					
					
						commit
						a90e996b7d
					
				
							
								
								
									
										19
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								Makefile
									
									
									
									
									
								
							| @ -3,6 +3,7 @@ VERSION := $(shell cat VERSION) | ||||
| BUILD_DIR := build | ||||
| DIST_DIR := dist | ||||
| LDFLAGS := "-w -s" | ||||
| VVERSION := v$(VERSION) | ||||
| 
 | ||||
| build: | ||||
| 	@echo "Building for this platform ..." | ||||
| @ -13,30 +14,28 @@ build: | ||||
| 
 | ||||
| .PHONY: release | ||||
| release: | ||||
| 	# Check if the git working directory is clean | ||||
| 	@echo "Check if the git working directory is clean" | ||||
| 	@if [ -n "$$(git status --porcelain)" ]; then \
 | ||||
| 		echo "Error: The working directory is not clean. Please commit or stash your changes."; \
 | ||||
| 		exit 1; \
 | ||||
| 	fi | ||||
| 
 | ||||
| 	VVERSION=v$(VERSION) | ||||
| 
 | ||||
| 	# Check if the version tag already exists and does not point to HEAD | ||||
| 	@if git rev-parse $$VVERSION >/dev/null 2>&1; then \
 | ||||
| 	@echo "Check if the version tag already exists and does not point to HEAD" | ||||
| 	@if git rev-parse $(VVERSION) >/dev/null 2>&1; then \
 | ||||
| 		if ! git describe --tags --exact-match HEAD >/dev/null 2>&1; then \
 | ||||
| 			echo "Error: Version $$VVERSION is already tagged on a different commit."; \
 | ||||
| 			echo "Error: Version $(VVERSION) is already tagged on a different commit."; \
 | ||||
| 			exit 1; \
 | ||||
| 		fi; \
 | ||||
| 	fi | ||||
| 
 | ||||
| 	# Tag the latest commit with the version from VERSION file if not already tagged | ||||
| 	@echo "Tag the latest commit with the version from VERSION file if not already tagged" | ||||
| 	@if ! git describe --tags --exact-match HEAD >/dev/null 2>&1; then \
 | ||||
| 		echo "Latest commit not tagged. Tagging with version from VERSION file..."; \
 | ||||
| 		git tag -a $$VVERSION -m "Release $$VVERSION"; \
 | ||||
| 		git push origin $$VVERSION; \
 | ||||
| 		git tag -a $(VVERSION) -m "Release $(VVERSION)"; \
 | ||||
| 		git push origin $(VVERSION); \
 | ||||
| 	fi | ||||
| 
 | ||||
| 	# Set GITEA_TOKEN variable and run goreleaser | ||||
| 	@echo "Set GITEA_TOKEN variable and run goreleaser" | ||||
| 	@$(eval GITEA_TOKEN=$(shell pass www/behzadan.ir/git/reza/tokens/dt06-goreleaser)) | ||||
| 	@goreleaser release | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user