Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.
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
9 changes: 3 additions & 6 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[bumpversion]
current_version = 4.0.7
commit = True
parse = (?P<major>\d+)(\.(?P<minor>\d+))(\.(?P<patch>\d+))(\-(?P<release>.*))?
serialize =
{major}.{minor}.{patch}-{release}
{major}.{minor}.{patch}
tag = False

[bumpversion:file:VERSION]

[bumpversion:file:pyproject.toml]

[bumpversion:file:src/halpi/const.py]
search = version = "{current_version}"
replace = version = "{new_version}"
23 changes: 23 additions & 0 deletions .github/actions/build-deb/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Build Debian Package'
description: 'Build HALPI2 daemon .deb package'

runs:
using: 'composite'
steps:
- name: Create minimal .env file
run: |
if [ ! -f .env ]; then
echo "# Environment file for GitHub Actions" > .env
fi
shell: bash

- name: Build package
run: ./run docker-build-deb
shell: bash

- name: Collect built packages
run: |
# Find .deb files created by dpkg-buildpackage (in parent directory)
find . .. -maxdepth 1 -name "*.deb" -exec mv {} ./ \; 2>/dev/null || true
ls -lh *.deb
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/run-tests/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Run Tests'
description: 'Run Python tests for HALPI2 daemon'

runs:
using: 'composite'
steps:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Run tests
run: uv run pytest
shell: bash
79 changes: 79 additions & 0 deletions .github/scripts/check-release-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
# Check if a release exists and set output flags
# Usage: check-release-exists.sh <VERSION> [RELEASE_TYPE]
# RELEASE_TYPE: "prerelease" (default), "draft", or "stable"

set -e

VERSION="${1:?Version required}"
RELEASE_TYPE="${2:-prerelease}"

if [ -z "$VERSION" ]; then
echo "Error: VERSION argument required"
exit 1
fi

case "$RELEASE_TYPE" in
prerelease)
# Check if published (non-prerelease) release with same or higher version exists
HIGHEST_STABLE=$(gh release list --limit 100 --json tagName,isPrerelease,isDraft \
--jq '.[] | select(.isDraft == false and .isPrerelease == false) | .tagName' | \
sed 's/^v//' | sort -V | tail -n1)

if [ -n "$HIGHEST_STABLE" ]; then
echo "Found highest stable release: v${HIGHEST_STABLE}"
# Compare versions using dpkg --compare-versions
# Strip Debian revision from VERSION for comparison (0.2.0-1 → 0.2.0)
# Note: ${VERSION%-*} is safe - if VERSION has no dash, it returns VERSION unchanged
if dpkg --compare-versions "${VERSION%-*}" le "$HIGHEST_STABLE"; then
echo "action=skip" >> "$GITHUB_OUTPUT"
echo "⏭️ Stable release v${HIGHEST_STABLE} >= v${VERSION%-*} - skipping pre-release"
exit 0
fi
fi
echo "action=create" >> "$GITHUB_OUTPUT"
echo "✅ No published release with same or higher version - will create pre-release v${VERSION%-*}"
;;

draft)
# Check if release exists (any kind)
if gh release view "v$VERSION" &>/dev/null; then
IS_DRAFT=$(gh release view "v$VERSION" --json isDraft --jq '.isDraft')
if [ "$IS_DRAFT" = "true" ]; then
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "delete_existing=true" >> "$GITHUB_OUTPUT"
echo "Existing draft release found - will delete and recreate"
else
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "delete_existing=false" >> "$GITHUB_OUTPUT"
echo "Published release v$VERSION already exists - skipping"
fi
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "delete_existing=false" >> "$GITHUB_OUTPUT"
echo "No existing release found"
fi
;;

stable)
# For stable releases, check if prerelease exists to delete first
if gh release view "v$VERSION" &>/dev/null; then
IS_PRERELEASE=$(gh release view "v$VERSION" --json isPrerelease --jq '.isPrerelease')
if [ "$IS_PRERELEASE" = "true" ]; then
echo "action=delete" >> "$GITHUB_OUTPUT"
echo "🗑️ Existing pre-release v$VERSION found - will delete before creating stable"
else
echo "action=skip" >> "$GITHUB_OUTPUT"
echo "⏭️ Published release v$VERSION already exists - skipping"
fi
else
echo "action=create" >> "$GITHUB_OUTPUT"
echo "✅ No existing release found - will create v$VERSION"
fi
;;

*)
echo "Error: Unknown RELEASE_TYPE '$RELEASE_TYPE'. Use 'prerelease', 'draft', or 'stable'"
exit 1
;;
esac
145 changes: 145 additions & 0 deletions .github/scripts/generate-release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/bin/bash
# Generate release notes for a release
# Usage: generate-release-notes.sh <VERSION> <TAG_VERSION> <RELEASE_TYPE>
# RELEASE_TYPE: "prerelease", "draft", or "stable"

set -e

VERSION="${1:?Version required}"
TAG_VERSION="${2:?Tag version required}"
RELEASE_TYPE="${3:?Release type required}"

if [ -z "$VERSION" ] || [ -z "$TAG_VERSION" ] || [ -z "$RELEASE_TYPE" ]; then
echo "Usage: generate-release-notes.sh <VERSION> <TAG_VERSION> <RELEASE_TYPE>"
exit 1
fi

SHORT_SHA="${GITHUB_SHA:0:7}"

# Get the latest published (non-prerelease) release
LAST_TAG=$(gh release list --limit 100 --json tagName,isPrerelease,isDraft \
--jq '.[] | select(.isDraft == false and .isPrerelease == false) | .tagName' | head -n1)

if [ -n "$LAST_TAG" ]; then
echo "Generating changelog since $LAST_TAG"
CHANGELOG=$(git log "${LAST_TAG}"..HEAD --pretty=format:"- %s (%h)" --no-merges --)
else
echo "No previous published releases found, using recent commits"
CHANGELOG=$(git log -10 --pretty=format:"- %s (%h)" --no-merges)
fi

case "$RELEASE_TYPE" in
prerelease)
cat > release_notes.md <<EOF
## HALPI2 Daemon v${TAG_VERSION} (Pre-release)

⚠️ **This is a pre-release build from the main branch. Use for testing only.**

**Build Information:**
- Commit: ${SHORT_SHA} (\`${GITHUB_SHA}\`)
- Built: $(date -u '+%Y-%m-%d %H:%M:%S UTC')

### Recent Changes

${CHANGELOG}

### Installation

To install this pre-release on your HALPI2:

\`\`\`bash
# Add Hat Labs repository (if not already added)
curl -fsSL https://apt.hatlabs.fi/hat-labs-apt-key.asc | sudo gpg --dearmor -o /usr/share/keyrings/hatlabs-apt-key.gpg

# Add unstable channel
echo "deb [signed-by=/usr/share/keyrings/hatlabs-apt-key.gpg] https://apt.hatlabs.fi unstable main" | sudo tee /etc/apt/sources.list.d/hatlabs-unstable.list

# Update and install
sudo apt update
sudo apt install halpid
\`\`\`

EOF
;;

draft)
cat > release_notes.md <<EOF
## HALPI2 Daemon v${VERSION}

Power monitor and watchdog service for HALPI2 - the Raspberry Pi CM5 based boat computer.

### Changes

${CHANGELOG}

### Features

- **Blackout Reporting**: Monitor input voltage and detect power loss
- **Automatic Shutdown**: Trigger safe system shutdown when power isn't restored
- **Supercap Voltage Monitoring**: Track backup power status
- **Watchdog Functionality**: Automatic hard reset if communication fails
- **RTC Sleep Mode**: Schedule wake times for battery-powered operations
- **USB Power Control**: Power-cycle USB ports for unresponsive devices

### Installation

This is the source code release. For Debian packages:

\`\`\`bash
sudo apt install halpid
\`\`\`

See [apt.hatlabs.fi](https://github.com/hatlabs/apt.hatlabs.fi) for repository setup.

### Development

For development setup and build commands, see:
- [README.md](https://github.com/hatlabs/HALPI2-daemon/blob/main/README.md) - Installation and usage
- \`./run help\` - Available build and development commands
EOF
;;

stable)
cat > release_notes.md <<EOF
## HALPI2 Daemon v${VERSION}

Power monitor and watchdog service for HALPI2 - the Raspberry Pi CM5 based boat computer.

### Changes

${CHANGELOG}

### Features

- **Blackout Reporting**: Monitor input voltage and detect power loss
- **Automatic Shutdown**: Trigger safe system shutdown when power isn't restored
- **Supercap Voltage Monitoring**: Track backup power status
- **Watchdog Functionality**: Automatic hard reset if communication fails
- **RTC Sleep Mode**: Schedule wake times for battery-powered operations
- **USB Power Control**: Power-cycle USB ports for unresponsive devices

### Installation

This is the source code release. For Debian packages:

\`\`\`bash
sudo apt install halpid
\`\`\`

See [apt.hatlabs.fi](https://github.com/hatlabs/apt.hatlabs.fi) for repository setup.

### Development

For development setup and build commands, see:
- [README.md](https://github.com/hatlabs/HALPI2-daemon/blob/main/README.md) - Installation and usage
- \`./run help\` - Available build and development commands
EOF
;;

*)
echo "Error: Unknown RELEASE_TYPE '$RELEASE_TYPE'. Use 'prerelease', 'draft', or 'stable'"
exit 1
;;
esac

echo "Release notes created"
13 changes: 13 additions & 0 deletions .github/scripts/read-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
# Read version from VERSION file
# Sets version and tag_version in GitHub output

set -e

VERSION=$(cat VERSION | tr -d '\n\r ')
# For daemon, version and tag_version are the same
TAG_VERSION="$VERSION"

echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag_version=$TAG_VERSION" >> "$GITHUB_OUTPUT"
echo "Version from VERSION file: $VERSION (tag version: $TAG_VERSION)"
45 changes: 0 additions & 45 deletions .github/workflows/build.yml

This file was deleted.

Loading