Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
nana4rider committed Jan 16, 2025
1 parent b2df513 commit 36311d7
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 2 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Release

on:
push:
branches:
- main

jobs:
test:
uses: ./.github/workflows/test.yml

get-version:
needs: test
runs-on: ubuntu-latest
outputs:
current: ${{ steps.current.outputs.version }}
previous: ${{ steps.previous.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- id: current
run: |
VERSION=$(jq -r '.version' package.json)
echo "current: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- id: previous
run: |
VERSION=$(git show HEAD~1:package.json | jq -r '.version')
echo "previous: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: get-version
if: ${{ needs.get-version.outputs.current != needs.get-version.outputs.previous }}
steps:
- uses: actions/checkout@v4

- name: Add Tag
run: |
git tag "v${{ needs.get-version.outputs.current }}"
git push origin "v${{ needs.get-version.outputs.current }}"
- name: Create Release to GitHub
run: gh release create "v${{ needs.get-version.outputs.current }}" --generate-notes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-and-publish:
runs-on: ubuntu-latest
needs: get-version
if: ${{ needs.get-version.outputs.current != needs.get-version.outputs.previous }}
steps:
- name: checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ github.repository }}
tags: |
type=raw,value=latest
type=raw,value=v${{ needs.get-version.outputs.current }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}

deploy-webhook:
runs-on: ubuntu-latest
needs: build-and-publish
steps:
- env:
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
run: |
TIMESTAMP=$(date +%s)
SIGNATURE=$(echo -n "$TIMESTAMP" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | awk '{print $2}')
curl -X POST "$WEBHOOK_URL" \
-H "X-Signature: $SIGNATURE" \
-H "X-Timestamp: $TIMESTAMP"
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
workflow_call:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"

- run: npm ci

- run: npm run lint

- run: npm run build

- run: npm test
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ FROM node:22-alpine AS runtime

WORKDIR /app
COPY --chown=node:node --from=build /app/package*.json ./
COPY --chown=node:node --from=build /app/dist dist
RUN npm ci --omit=dev --ignore-scripts
COPY --from=build /app/dist dist

USER node
EXPOSE 3000
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@
ECHONET Liteプロトコルを使用して、Wi-SUN対応スマートメーターから取得したデータを解析し、Home AssistantのMQTT Discovery形式で公開するアプリケーションです。

このアプリケーションにより、スマートメーターの情報をHome Assistantに自動登録し、エネルギー使用量のモニタリングや管理を簡単に行えます。

## エンティティ一覧

![Home Assistant](images/homeassistant.png)

## サポートデバイス

- [BP35C2](https://www.furutaka-netsel.co.jp/maker/rohm/bp35c2)
1 change: 1 addition & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ await build({
js: 'import { createRequire } from "module"; import url from "url"; const require = createRequire(import.meta.url); const __filename = url.fileURLToPath(import.meta.url); const __dirname = url.fileURLToPath(new URL(".", import.meta.url));',
},
loader: { ".node": "file" },
packages: "external",
});
Binary file added images/homeassistant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wisun2mqtt",
"version": "0.2.0",
"version": "1.0.0",
"main": "dist/index.js",
"type": "module",
"homepage": "https://github.com/nana4rider/wisun2mqtt",
Expand Down

0 comments on commit 36311d7

Please sign in to comment.