Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ jobs:
git fetch origin develop
git checkout develop
git pull origin develop

- name: Determine Release Version
id: version
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
VERSION=${{ github.event.inputs.release_version }}
else
LAST_TAG=$(git tag --sort=-v:refname | head -n 1 | sed 's/v//')
IFS='.' read -r major minor patch <<< "$LAST_TAG"
VERSION="$major.$minor.$((patch + 1))"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Release version set to $VERSION"

- name: Check if Main Branch Exists and Merge
run: |
Expand All @@ -54,19 +67,6 @@ jobs:
with:
node-version: lts/*

- name: Determine Release Version
id: version
run: |
if [ -n "${{ github.event.inputs.release_version }}" ]; then
VERSION=${{ github.event.inputs.release_version }}
else
LAST_TAG=$(git tag --sort=-v:refname | head -n 1 | sed 's/v//')
IFS='.' read -r major minor patch <<< "$LAST_TAG"
VERSION="$major.$minor.$((patch + 1))"
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "Release version set to $VERSION"

- name: Verify Version in Code
run: |
VERSION_IN_CODE=$(grep "CurrentVersion =" internal/commands/version.go | awk -F'"' '{print $2}')
Expand Down Expand Up @@ -101,26 +101,20 @@ jobs:

- name: Build Cross-Platform Binaries
run: |
if [ -z "${{ vars.PROJECT_NAME }}" ]; then
PROJECT_NAME="enemeter-data-processing"
echo "Using default project name: $PROJECT_NAME"
else
if [ -z "${{ vars.PROJECT_NAME }}" ]; then
echo "ERROR: PROJECT_NAME GitHub variable is not set. Please set it in repository settings."
exit 1
fi

PROJECT_NAME="${{ vars.PROJECT_NAME }}"
echo "Using project name from settings: $PROJECT_NAME"
fi

go mod tidy
echo "Building CLI for version $VERSION"

make build-all VERSION=$VERSION
echo "Using project name: $PROJECT_NAME"
go mod tidy
echo "Building CLI for version $VERSION"
make build-all VERSION=$VERSION

- name: Create GitHub Release
run: |
PROJECT_NAME="${{ vars.PROJECT_NAME }}"
if [ -z "$PROJECT_NAME" ]; then
PROJECT_NAME="enemeter-data-processing"
fi

gh release create "v${VERSION}" \
--title "Release v${VERSION}" \
--notes-file docs/CHANGELOG.md \
Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
VERSION ?= 1.0.0
PROJECT_NAME = enemeter-data-processing

.PHONY: build build-all clean test
.PHONY: build build-all clean test build-analyze

build:
mkdir -p dist
go build -o dist/$(PROJECT_NAME) ./cmd/$(PROJECT_NAME)

build-all:
build-analyze:
mkdir -p dist
@echo "Building for Linux..."
go build -o dist/analyze-csv ./cmd/analyze-csv

build-all: build build-analyze
mkdir -p dist
@echo "Building $(PROJECT_NAME) for Linux..."
GOOS=linux GOARCH=amd64 go build -o dist/$(PROJECT_NAME)-linux -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)
@echo "Building for Windows..."
@echo "Building $(PROJECT_NAME) for Windows..."
GOOS=windows GOARCH=amd64 go build -o dist/$(PROJECT_NAME).exe -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)
@echo "Building for macOS..."
@echo "Building $(PROJECT_NAME) for macOS..."
GOOS=darwin GOARCH=amd64 go build -o dist/$(PROJECT_NAME)-mac -ldflags="-X '$(PROJECT_NAME)/internal/commands.CurrentVersion=$(VERSION)'" ./cmd/$(PROJECT_NAME)

@echo "Building analyze-csv for Linux..."
GOOS=linux GOARCH=amd64 go build -o dist/analyze-csv-linux ./cmd/analyze-csv
@echo "Building analyze-csv for Windows..."
GOOS=windows GOARCH=amd64 go build -o dist/analyze-csv.exe ./cmd/analyze-csv
@echo "Building analyze-csv for macOS..."
GOOS=darwin GOARCH=amd64 go build -o dist/analyze-csv-mac ./cmd/analyze-csv

@echo "Build completed. Contents of dist/:"
@ls -lh dist/

Expand Down
Loading