Skip to content

Commit c366fa4

Browse files
committed
feat: initial mvp implementation of ENEMETER Data Processing Tool (#1)
* feat: initial mvp implementation of ENEMETER Data Processing Tool * fix: handle file.Close() error in all three places by using defer with a function that checks the close error, include MaxRecords check within Parse function loop and remove the unused calculateAverage function
1 parent f53f7a8 commit c366fa4

13 files changed

Lines changed: 1723 additions & 69 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
id: app-token
1717
uses: actions/create-github-app-token@v1
1818
with:
19-
app-id: \${{ vars.RUBRION_APP_ID }}
20-
private-key: \${{ secrets.RUBRION_APP_SECRET }}
19+
app-id: ${{ vars.RUBRION_APP_ID }}
20+
private-key: ${{ secrets.RUBRION_APP_SECRET }}
2121

2222
- name: Set Git User Identity
2323
run: |
@@ -29,19 +29,25 @@ jobs:
2929
with:
3030
fetch-depth: 0
3131
ref: develop
32-
token: \${{ steps.app-token.outputs.token }}
32+
token: ${{ steps.app-token.outputs.token }}
3333

3434
- name: Ensure Develop is Up to Date
3535
run: |
3636
git fetch origin develop
3737
git checkout develop
3838
git pull origin develop
3939
40-
- name: Merge Develop into Main
40+
- name: Check if Main Branch Exists and Merge
4141
run: |
42-
git checkout main
43-
git merge --no-ff develop
44-
git push origin main
42+
if git ls-remote --heads origin main | grep main; then
43+
echo "Main branch exists, proceeding with merge"
44+
git checkout main || git checkout -b main
45+
git merge --no-ff develop -m "chore: merge develop into main for release v${VERSION}"
46+
else
47+
echo "Main branch does not exist, creating from develop"
48+
git checkout -b main
49+
fi
50+
git push -u origin main
4551
4652
- name: Setup Node.js
4753
uses: actions/setup-node@v4
@@ -51,15 +57,15 @@ jobs:
5157
- name: Determine Release Version
5258
id: version
5359
run: |
54-
if [ -n "\${{ github.event.inputs.release_version }}" ]; then
55-
VERSION=\${{ github.event.inputs.release_version }}
60+
if [ -n "${{ github.event.inputs.release_version }}" ]; then
61+
VERSION=${{ github.event.inputs.release_version }}
5662
else
57-
LAST_TAG=\$(git tag --sort=-v:refname | head -n 1 | sed 's/v//')
58-
IFS='.' read -r major minor patch <<< "\$LAST_TAG"
59-
VERSION="\$major.\$minor.\$((patch + 1))"
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))"
6066
fi
61-
echo "VERSION=\$VERSION" >> \$GITHUB_ENV
62-
echo "Release version set to \$VERSION"
67+
echo "VERSION=$VERSION" >> $GITHUB_ENV
68+
echo "Release version set to $VERSION"
6369
6470
- name: Verify Version in Code
6571
run: |
@@ -85,7 +91,7 @@ jobs:
8591
8692
- name: Create Git Tag
8793
run: |
88-
git tag "v\${VERSION}"
94+
git tag "v${VERSION}"
8995
git push origin --tags
9096
9197
- name: Set Up Go
@@ -95,31 +101,31 @@ jobs:
95101

96102
- name: Build Cross-Platform Binaries
97103
run: |
98-
if [ -z "\${{ vars.PROJECT_NAME }}" ]; then
104+
if [ -z "${{ vars.PROJECT_NAME }}" ]; then
99105
echo "ERROR: PROJECT_NAME GitHub variable is not set. Please set it in repository settings."
100106
exit 1
101107
fi
102108
103-
PROJECT_NAME="\${{ vars.PROJECT_NAME }}"
104-
echo "Using project name: \$PROJECT_NAME"
109+
PROJECT_NAME="${{ vars.PROJECT_NAME }}"
110+
echo "Using project name: $PROJECT_NAME"
105111
106112
go mod tidy
107-
echo "Building CLI for version \$VERSION"
113+
echo "Building CLI for version $VERSION"
108114
mkdir -p dist
109115
110-
GOOS=linux GOARCH=amd64 go build -o dist/\$PROJECT_NAME-linux -ldflags="-X '\$PROJECT_NAME/commands.CurrentVersion=\${VERSION}'" main.go || exit 1
111-
GOOS=windows GOARCH=amd64 go build -o dist/\$PROJECT_NAME.exe -ldflags="-X '\$PROJECT_NAME/commands.CurrentVersion=\${VERSION}'" main.go || exit 1
112-
GOOS=darwin GOARCH=amd64 go build -o dist/\$PROJECT_NAME-mac -ldflags="-X '\$PROJECT_NAME/commands.CurrentVersion=\${VERSION}'" main.go || exit 1
116+
GOOS=linux GOARCH=amd64 go build -o dist/$PROJECT_NAME-linux -ldflags="-X '$PROJECT_NAME/commands.CurrentVersion=${VERSION}'" main.go || exit 1
117+
GOOS=windows GOARCH=amd64 go build -o dist/$PROJECT_NAME.exe -ldflags="-X '$PROJECT_NAME/commands.CurrentVersion=${VERSION}'" main.go || exit 1
118+
GOOS=darwin GOARCH=amd64 go build -o dist/$PROJECT_NAME-mac -ldflags="-X '$PROJECT_NAME/commands.CurrentVersion=${VERSION}'" main.go || exit 1
113119

114120
echo "Build completed. Contents of dist/:"
115121
ls -lh dist/
116122

117123
- name: Create GitHub Release
118124
run: |
119-
PROJECT_NAME="\${{ vars.PROJECT_NAME }}"
120-
gh release create "v\${VERSION}" \
121-
--title "Release v\${VERSION}" \
125+
PROJECT_NAME="${{ vars.PROJECT_NAME }}"
126+
gh release create "v${VERSION}" \
127+
--title "Release v${VERSION}" \
122128
--notes-file CHANGELOG.md \
123-
dist/\$PROJECT_NAME-linux dist/\$PROJECT_NAME.exe dist/\$PROJECT_NAME-mac
129+
dist/$PROJECT_NAME-linux dist/$PROJECT_NAME.exe dist/$PROJECT_NAME-mac
124130
env:
125-
GH_TOKEN: \${{ secrets.GITHUB_TOKEN }}
131+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/qa.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ jobs:
1919

2020
- name: Configure Go Module Cache
2121
run: |
22-
mkdir -p \$HOME/.cache/go-mod
23-
echo "export GOMODCACHE=\$HOME/.cache/go-mod" >> \$GITHUB_ENV
22+
mkdir -p $HOME/.cache/go-mod
23+
echo "export GOMODCACHE=$HOME/.cache/go-mod" >> $GITHUB_ENV
2424
2525
- name: Cache Go modules
2626
uses: actions/cache@v3
2727
with:
28-
path: \$HOME/.cache/go-mod
29-
key: \${{ runner.os }}-go-\${{ hashFiles('**/go.sum') }}
28+
path: $HOME/.cache/go-mod
29+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3030
restore-keys: |
31-
\${{ runner.os }}-go-
31+
${{ runner.os }}-go-
3232
3333
- name: Install Dependencies
3434
run: go mod download

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Exclude build files
22
dist/
3+
data/
34
vendor/
4-
.env
5+
.env

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build:
2-
go build -o dist/rubrion-cli ./cmd/rubrion-cli/main.go
2+
go build -o dist/enemeter-data-processing ./cmd/enemeter-data-processing/main.go
33

44
.PHONY: build

0 commit comments

Comments
 (0)