feat: initial scaffold and profiles for Schneider iEM2135, LUG heat meter v4
Seed the repo described in pda-fieldbus ADR-0009: a sibling repo that
ships device profiles independently of the fieldbus binary.
Layout:
- profiles/schneider-iem2135.json — distilled from the inline extract
rules in examples/poll-d27-g110.yaml
- profiles/lug-heat-meter-v4.json — heat-meter profile with derived
delta_temperature
Both validate against pda-fieldbus's profile.LoadDirs.
Packaging:
- nfpm.yaml builds pda-fieldbus-profiles.deb installing profiles/ to
/usr/share/pda-fieldbus/profiles/, where the loader's DirPackaged dir
picks them up. Recommends pda-fieldbus.
- .gitea/workflows/auto-tag.yml: same conventional-commit auto-tagging
as pda-fieldbus, on tag push installs nfpm, builds .deb, uploads to
repo.pda.cz/PDAT/main using the existing PDA_REPO_TOKEN secret.
- .gitea/workflows/ci.yml: JSON syntax check + schema validation by
importing pda-fieldbus's loader and calling LoadDirs against profiles/.
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
name: Auto Tag
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
tag:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
new_tag: ${{ steps.bump.outputs.new_tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Determine version bump and create tag
|
||||
id: bump
|
||||
run: |
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "Latest tag: $LATEST_TAG"
|
||||
|
||||
COMMITS=$(git log "${LATEST_TAG}..HEAD" --pretty=format:"%s" 2>/dev/null)
|
||||
if [ -z "$COMMITS" ]; then
|
||||
echo "No new commits since ${LATEST_TAG}, skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
BUMP=""
|
||||
if echo "$COMMITS" | grep -qiE "^[a-z]+(\(.+\))?!:|BREAKING CHANGE"; then
|
||||
BUMP="major"
|
||||
elif echo "$COMMITS" | grep -qiE "^feat(\(.+\))?:"; then
|
||||
BUMP="minor"
|
||||
elif echo "$COMMITS" | grep -qiE "^fix(\(.+\))?:"; then
|
||||
BUMP="patch"
|
||||
fi
|
||||
|
||||
if [ -z "$BUMP" ]; then
|
||||
echo "No conventional commit triggers, skipping."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
VERSION="${LATEST_TAG#v}"
|
||||
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||
MINOR=$(echo "$VERSION" | cut -d. -f2)
|
||||
PATCH=$(echo "$VERSION" | cut -d. -f3)
|
||||
|
||||
case "$BUMP" in
|
||||
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
|
||||
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
|
||||
patch) PATCH=$((PATCH + 1)) ;;
|
||||
esac
|
||||
|
||||
NEW_TAG="v${MAJOR}.${MINOR}.${PATCH}"
|
||||
echo "Creating tag: $NEW_TAG"
|
||||
|
||||
git tag "$NEW_TAG"
|
||||
git push origin "$NEW_TAG"
|
||||
echo "new_tag=$NEW_TAG" >> "$GITHUB_OUTPUT"
|
||||
|
||||
release:
|
||||
needs: tag
|
||||
if: needs.tag.outputs.new_tag != ''
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ needs.tag.outputs.new_tag }}
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.25"
|
||||
cache: false
|
||||
|
||||
- name: Install nfpm
|
||||
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.41.3
|
||||
|
||||
- name: Build .deb
|
||||
run: |
|
||||
VER="${{ needs.tag.outputs.new_tag }}"
|
||||
VER="${VER#v}"
|
||||
mkdir -p dist
|
||||
VERSION="$VER" nfpm pkg --packager deb --target dist/ -f nfpm.yaml
|
||||
ls -la dist/
|
||||
|
||||
- name: Publish .deb to repo.pda.cz
|
||||
run: |
|
||||
for deb in dist/*.deb; do
|
||||
echo "Uploading $deb"
|
||||
curl --fail -X POST https://repo.pda.cz/api/v1/PDAT/main/upload \
|
||||
-H "Authorization: Bearer ${{ secrets.PDA_REPO_TOKEN }}" \
|
||||
-F "file=@${deb}"
|
||||
done
|
||||
@@ -0,0 +1,60 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.25"
|
||||
cache: false
|
||||
|
||||
- name: JSON syntax check
|
||||
run: |
|
||||
for f in profiles/*.json; do
|
||||
echo "checking $f"
|
||||
python3 -m json.tool "$f" > /dev/null
|
||||
done
|
||||
|
||||
- name: Schema validation via pda-fieldbus loader
|
||||
working-directory: ${{ runner.temp }}
|
||||
run: |
|
||||
mkdir -p validator && cd validator
|
||||
go mod init validator
|
||||
go get github.com/pdat-cz/pda-fieldbus@latest
|
||||
cat > main.go <<'EOF'
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/pdat-cz/pda-fieldbus/pkg/proto/profile"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Fprintln(os.Stderr, "usage: validator <profiles-dir>")
|
||||
os.Exit(2)
|
||||
}
|
||||
m, err := profile.LoadDirs(os.Args[1])
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "FAIL:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for n, p := range m {
|
||||
fmt.Printf("OK %s device=%s/%s points=%d derived=%d\n",
|
||||
n, p.Device.Manufacturer, p.Device.Model,
|
||||
len(p.Points), len(p.Derived))
|
||||
}
|
||||
}
|
||||
EOF
|
||||
go run . "$GITHUB_WORKSPACE/profiles"
|
||||
Reference in New Issue
Block a user