Skip to content

chore: bump version to 1.6.1 #69

chore: bump version to 1.6.1

chore: bump version to 1.6.1 #69

name: Build and Deploy Home Assistant Addon
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
DISTRIBUTION_REPO: 'dougrathbone/cgateweb-homeassistant'
jobs:
test:
strategy:
matrix:
node-version: [20.x, 22.x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint -- --max-warnings=0
- run: npm test -- --coverage
build-and-deploy:
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout source repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Get version from tag
id: version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
VERSION=${VERSION#v}
else
VERSION=$(date +%Y%m%d-%H%M%S)-${GITHUB_SHA:0:7}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Build distribution structure
run: |
# HA addon repos require: repository.yaml at root, each addon in a subfolder
mkdir -p distribution/cgateweb
# Copy addon metadata files into the addon subfolder
cp homeassistant-addon/config.yaml distribution/cgateweb/
cp homeassistant-addon/Dockerfile distribution/cgateweb/
cp homeassistant-addon/build.yaml distribution/cgateweb/
cp homeassistant-addon/run.sh distribution/cgateweb/
cp homeassistant-addon/DOCS.md distribution/cgateweb/
cp homeassistant-addon/CHANGELOG.md distribution/cgateweb/
cp homeassistant-addon/README.md distribution/cgateweb/
cp homeassistant-addon/icon.png distribution/cgateweb/
cp homeassistant-addon/logo.png distribution/cgateweb/
# Copy translations
cp -r homeassistant-addon/translations distribution/cgateweb/
# Copy rootfs (s6-overlay services)
cp -r homeassistant-addon/rootfs distribution/cgateweb/
# Copy application source
cp -r src distribution/cgateweb/
cp -r public distribution/cgateweb/
cp index.js distribution/cgateweb/
cp package.json distribution/cgateweb/
cp package-lock.json distribution/cgateweb/
# Update version in config.yaml
sed -i "s/version: .*/version: \"${{ steps.version.outputs.version }}\"/" distribution/cgateweb/config.yaml
# Copy repository-level branding and documentation
cp homeassistant-addon/logo.png distribution/
cp homeassistant-addon/icon.png distribution/
cp homeassistant-addon/repository-README.md distribution/README.md
# Create repository.yaml at the distribution root
cat > distribution/repository.yaml << 'REPOEOF'
name: C-Gate Web Bridge Add-on Repository
url: https://github.com/dougrathbone/cgateweb-homeassistant
maintainer: Doug Rathbone <doug@dougrathbone.com>
REPOEOF
- name: Checkout or initialize distribution repository
run: |
if git clone https://${{ secrets.HACS_DEPLOY_TOKEN }}@github.com/${{ env.DISTRIBUTION_REPO }}.git hacs-repo 2>/dev/null; then
cd hacs-repo
if git show-ref --verify --quiet refs/heads/main; then
git checkout main
elif git show-ref --verify --quiet refs/heads/master; then
git checkout master
git branch -m master main
else
git checkout -b main
fi
else
mkdir hacs-repo
cd hacs-repo
git init --initial-branch=main
git remote add origin https://${{ secrets.HACS_DEPLOY_TOKEN }}@github.com/${{ env.DISTRIBUTION_REPO }}.git
fi
git config user.name 'cgateweb-bot'
git config user.email 'actions@github.com'
- name: Deploy to distribution repository
run: |
cd hacs-repo
# Clear existing content (except .git)
find . -mindepth 1 -name '.git' -prune -o -type f -exec rm {} + 2>/dev/null || true
find . -mindepth 1 -name '.git' -prune -o -type d -exec rm -rf {} + 2>/dev/null || true
# Copy new distribution files
cp -r ../distribution/* .
git add .
if git diff --staged --quiet; then
echo "No changes to deploy"
exit 0
fi
git commit -m "Release v${{ steps.version.outputs.version }}
Source: ${{ github.repository }}@${{ github.sha }}"
if ! git push -u origin main; then
echo "Failed to push to distribution repository"
exit 1
fi
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
repository: ${{ env.DISTRIBUTION_REPO }}
token: ${{ secrets.HACS_DEPLOY_TOKEN }}
tag_name: v${{ steps.version.outputs.version }}
name: v${{ steps.version.outputs.version }}
body: |
## C-Gate Web Bridge v${{ steps.version.outputs.version }}
Home Assistant add-on release.
### Installation
1. Add repository: `https://github.com/dougrathbone/cgateweb-homeassistant`
2. Install "C-Gate Web Bridge" from the add-on store
3. Configure C-Gate and MQTT settings
### Changes
See [main repository releases](https://github.com/dougrathbone/cgateweb/releases).
---
Source: ${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}
draft: false
prerelease: false