Skip to content

Commit 026f3f3

Browse files
authored
build: enhance the Makefile to build both main and analyze tools across platforms and fix blank version commit message (#3)
* build: enhance the Makefile to build both main and analyze tools across platforms and fix blank version commit message * ci: remove pipeline useless fallbacks
1 parent a176bd7 commit 026f3f3

File tree

2 files changed

+39
-34
lines changed

2 files changed

+39
-34
lines changed

.github/workflows/deploy.yml

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@ jobs:
3636
git fetch origin develop
3737
git checkout develop
3838
git pull origin develop
39+
40+
- name: Determine Release Version
41+
id: version
42+
run: |
43+
if [ -n "${{ github.event.inputs.release_version }}" ]; then
44+
VERSION=${{ github.event.inputs.release_version }}
45+
else
46+
LAST_TAG=$(git tag --sort=-v:refname | head -n 1 | sed 's/v//')
47+
IFS='.' read -r major minor patch <<< "$LAST_TAG"
48+
VERSION="$major.$minor.$((patch + 1))"
49+
fi
50+
echo "VERSION=$VERSION" >> $GITHUB_ENV
51+
echo "Release version set to $VERSION"
3952
4053
- name: Check if Main Branch Exists and Merge
4154
run: |
@@ -54,19 +67,6 @@ jobs:
5467
with:
5568
node-version: lts/*
5669

57-
- name: Determine Release Version
58-
id: version
59-
run: |
60-
if [ -n "${{ github.event.inputs.release_version }}" ]; then
61-
VERSION=${{ github.event.inputs.release_version }}
62-
else
63-
LAST_TAG=$(git tag --sort=-v:refname | head -n 1 | sed 's/v//')
64-
IFS='.' read -r major minor patch <<< "$LAST_TAG"
65-
VERSION="$major.$minor.$((patch + 1))"
66-
fi
67-
echo "VERSION=$VERSION" >> $GITHUB_ENV
68-
echo "Release version set to $VERSION"
69-
7070
- name: Verify Version in Code
7171
run: |
7272
VERSION_IN_CODE=$(grep "CurrentVersion =" internal/commands/version.go | awk -F'"' '{print $2}')
@@ -101,26 +101,20 @@ jobs:
101101

102102
- name: Build Cross-Platform Binaries
103103
run: |
104-
if [ -z "${{ vars.PROJECT_NAME }}" ]; then
105-
PROJECT_NAME="enemeter-data-processing"
106-
echo "Using default project name: $PROJECT_NAME"
107-
else
104+
if [ -z "${{ vars.PROJECT_NAME }}" ]; then
105+
echo "ERROR: PROJECT_NAME GitHub variable is not set. Please set it in repository settings."
106+
exit 1
107+
fi
108+
108109
PROJECT_NAME="${{ vars.PROJECT_NAME }}"
109-
echo "Using project name from settings: $PROJECT_NAME"
110-
fi
111-
112-
go mod tidy
113-
echo "Building CLI for version $VERSION"
114-
115-
make build-all VERSION=$VERSION
110+
echo "Using project name: $PROJECT_NAME"
111+
go mod tidy
112+
echo "Building CLI for version $VERSION"
113+
make build-all VERSION=$VERSION
116114
117115
- name: Create GitHub Release
118116
run: |
119117
PROJECT_NAME="${{ vars.PROJECT_NAME }}"
120-
if [ -z "$PROJECT_NAME" ]; then
121-
PROJECT_NAME="enemeter-data-processing"
122-
fi
123-
124118
gh release create "v${VERSION}" \
125119
--title "Release v${VERSION}" \
126120
--notes-file docs/CHANGELOG.md \

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
1-
VERSION ?= 1.0.0
21
PROJECT_NAME = enemeter-data-processing
32

4-
.PHONY: build build-all clean test
3+
.PHONY: build build-all clean test build-analyze
54

65
build:
76
mkdir -p dist
87
go build -o dist/$(PROJECT_NAME) ./cmd/$(PROJECT_NAME)
98

10-
build-all:
9+
build-analyze:
1110
mkdir -p dist
12-
@echo "Building for Linux..."
11+
go build -o dist/analyze-csv ./cmd/analyze-csv
12+
13+
build-all: build build-analyze
14+
mkdir -p dist
15+
@echo "Building $(PROJECT_NAME) for Linux..."
1316
GOOS=linux GOARCH=amd64 go build -o dist/$(PROJECT_NAME)-linux -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)
14-
@echo "Building for Windows..."
17+
@echo "Building $(PROJECT_NAME) for Windows..."
1518
GOOS=windows GOARCH=amd64 go build -o dist/$(PROJECT_NAME).exe -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)
16-
@echo "Building for macOS..."
19+
@echo "Building $(PROJECT_NAME) for macOS..."
1720
GOOS=darwin GOARCH=amd64 go build -o dist/$(PROJECT_NAME)-mac -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)
21+
22+
@echo "Building analyze-csv for Linux..."
23+
GOOS=linux GOARCH=amd64 go build -o dist/analyze-csv-linux ./cmd/analyze-csv
24+
@echo "Building analyze-csv for Windows..."
25+
GOOS=windows GOARCH=amd64 go build -o dist/analyze-csv.exe ./cmd/analyze-csv
26+
@echo "Building analyze-csv for macOS..."
27+
GOOS=darwin GOARCH=amd64 go build -o dist/analyze-csv-mac ./cmd/analyze-csv
28+
1829
@echo "Build completed. Contents of dist/:"
1930
@ls -lh dist/
2031

0 commit comments

Comments
 (0)