Skip to content

Commit 849984d

Browse files
Merge pull request #98 from Digital-Alchemy-TS/combineAddons
Combine addons
2 parents cde5790 + bbe68df commit 849984d

15 files changed

Lines changed: 274 additions & 80 deletions

File tree

.github/workflows/check.yml

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,55 @@ jobs:
1717
pull-requests: write
1818
checks: write
1919
steps:
20-
- uses: actions/checkout@v4
21-
22-
- uses: actions/setup-node@v4
20+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
22+
- uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # 6.1.0
2323
with:
2424
node-version: "22"
25-
cache: "yarn"
26-
25+
2726
- name: Enable Corepack
2827
run: corepack enable
29-
28+
3029
- name: Install dependencies
30+
run: yarn install
31+
32+
- name: Apply patches
3133
run: |
32-
yarn config set enableImmutableInstalls false
33-
yarn install
34-
34+
cd packages/paradigm
35+
bash scripts/patch-if-present.sh
36+
3537
- name: Run typecheck
36-
run: yarn typecheck
37-
38+
uses: EPMatt/reviewdog-action-tsc@63d923a3c5b4497671940b8874f58a404e2351b5 # 1.11.0
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
reporter: github-pr-review
42+
level: error
43+
fail_level: error
44+
3845
- name: Lint server (ESLint)
39-
run: |
40-
cd apps/server
41-
yarn lint --format json --output-file eslint-report.json || true
42-
yarn lint
43-
continue-on-error: true
44-
46+
uses: reviewdog/action-eslint@556a3fdaf8b4201d4d74d406013386aa4f7dab96 # 1.34.0
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
reporter: github-pr-review
50+
eslint_flags: "src/**/*.mts"
51+
workdir: apps/server
52+
fail_level: any
53+
4554
- name: Lint client (Biome)
46-
run: |
47-
cd apps/client
48-
yarn lint --reporter=github
49-
continue-on-error: true
50-
55+
uses: mongolyy/reviewdog-action-biome@abafdf75a79678ef8e2715298ee2dfc12262c82f #2.7.1
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
reporter: github-pr-review
59+
workdir: apps/client
60+
fail_level: any
61+
5162
- name: Lint paradigm (Biome)
52-
run: |
53-
cd packages/paradigm
54-
yarn lint --reporter=github
55-
continue-on-error: true
56-
63+
uses: mongolyy/reviewdog-action-biome@abafdf75a79678ef8e2715298ee2dfc12262c82f #2.7.1
64+
with:
65+
github_token: ${{ secrets.GITHUB_TOKEN }}
66+
reporter: github-pr-review
67+
workdir: packages/paradigm
68+
fail_level: any
69+
5770
- name: Run tests
5871
run: yarn test

.github/workflows/docker-build.yml

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ on:
44
push:
55
branches:
66
- main
7-
tags:
8-
- "v*"
7+
release:
8+
types: [published]
99
workflow_dispatch:
1010

1111
concurrency:
@@ -20,14 +20,59 @@ jobs:
2020
build-and-push:
2121
runs-on: ubuntu-latest
2222
permissions:
23-
contents: read
23+
contents: write
2424
packages: write
2525

2626
steps:
2727
- name: Checkout repository
2828
uses: actions/checkout@v4
2929
with:
3030
submodules: recursive
31+
fetch-depth: 0
32+
33+
- name: Bump dev version
34+
if: github.ref == 'refs/heads/main'
35+
id: bump_version
36+
run: |
37+
# Read current version from addon-dev config
38+
CURRENT_VERSION=$(grep '^version:' addon-dev/config.yaml | sed 's/version: "\(.*\)"/\1/')
39+
echo "Current version: $CURRENT_VERSION"
40+
41+
# Generate YY.M.N version based on current date
42+
YEAR=$(date +%y)
43+
MONTH=$(date +%-m)
44+
EXPECTED_BASE="${YEAR}.${MONTH}"
45+
46+
# Parse current version
47+
IFS='.' read -r CURRENT_YEAR CURRENT_MONTH CURRENT_RELEASE <<< "$CURRENT_VERSION"
48+
49+
# If we're in the same year/month, increment release number
50+
if [[ "${CURRENT_YEAR}.${CURRENT_MONTH}" == "${EXPECTED_BASE}" ]]; then
51+
NEW_RELEASE=$((CURRENT_RELEASE + 1))
52+
else
53+
# New month/year, start at .1
54+
NEW_RELEASE=1
55+
fi
56+
57+
NEW_VERSION="${EXPECTED_BASE}.${NEW_RELEASE}"
58+
echo "New version: $NEW_VERSION"
59+
60+
# Update addon-dev/config.yaml
61+
sed -i "s/^version: .*/version: \"${NEW_VERSION}\"/" addon-dev/config.yaml
62+
63+
# Output new version for later steps
64+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
65+
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
66+
67+
- name: Commit version bump
68+
if: github.ref == 'refs/heads/main'
69+
uses: stefanzweifel/git-auto-commit-action@v5
70+
with:
71+
commit_message: "🤖 bump dev version to ${{ steps.bump_version.outputs.version }}"
72+
file_pattern: addon-dev/config.yaml
73+
commit_options: "--no-verify"
74+
commit_user_name: github-actions[bot]
75+
commit_user_email: github-actions[bot]@users.noreply.github.com
3176

3277
- name: Set up QEMU
3378
uses: docker/setup-qemu-action@v3
@@ -42,19 +87,30 @@ jobs:
4287
username: ${{ github.actor }}
4388
password: ${{ secrets.GITHUB_TOKEN }}
4489

45-
- name: Determine Docker tags
90+
- name: Determine Docker tags and config
4691
id: tags
4792
run: |
4893
# Convert repository name to lowercase for Docker
4994
IMAGE_NAME_LOWER=$(echo "${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
50-
51-
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
52-
echo "tags=${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:dev" >> $GITHUB_OUTPUT
53-
elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then
54-
VERSION=${GITHUB_REF#refs/tags/v}
95+
96+
if [[ "${{ github.event_name }}" == "release" ]]; then
97+
# Extract version from release tag (remove 'v' prefix if present)
98+
VERSION="${{ github.event.release.tag_name }}"
99+
VERSION=${VERSION#v}
55100
echo "tags=${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:${VERSION},${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:latest" >> $GITHUB_OUTPUT
101+
echo "config_dir=addon" >> $GITHUB_OUTPUT
102+
103+
# Update addon/config.yaml with the release version
104+
sed -i "s/^version: .*/version: \"${VERSION}\"/" addon/config.yaml
105+
echo "Building production addon version ${VERSION}"
106+
elif [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
107+
echo "tags=${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:dev" >> $GITHUB_OUTPUT
108+
echo "config_dir=addon-dev" >> $GITHUB_OUTPUT
109+
echo "Building dev addon"
56110
else
57111
echo "tags=${{ env.REGISTRY }}/${IMAGE_NAME_LOWER}:${{ github.sha }}" >> $GITHUB_OUTPUT
112+
echo "config_dir=addon-dev" >> $GITHUB_OUTPUT
113+
echo "Building dev addon (non-main branch)"
58114
fi
59115
60116
- name: Build and push Docker image

README.md

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,34 @@
44

55
Code Glue is a Home Assistant add-on that lets you create and edit entities and automations using TypeScript and Digital Alchemy from within an embedded IDE.
66

7-
## 🔧 Install (Add custom add-on repository)
7+
## 🔧 Install
8+
9+
[![Add repository on my Home Assistant][repository-badge]][repository-url]
810

911
1. In Home Assistant, go to: Settings → Add-ons → Add-on Store
1012
2. Click the three dots (⋮) in the top-right → Repositories
1113
3. Add this URL as a custom repository:
1214

13-
- https://github.com/Digital-Alchemy-TS/code-glue-addon
15+
- https://github.com/Digital-Alchemy-TS/code-glue
16+
17+
4. Close the dialog
18+
19+
You'll now see two add-ons available:
20+
21+
### Available Add-ons
1422

15-
4. Close the dialog, search for "Code Glue," and open the add-on
16-
5. Click Install, then Start
17-
6. Optional: enable "Start on boot" and "Show in sidebar"
18-
7. Open the add-on via the sidebar or its Web UI
19-
8. 💰 Profit!
23+
#### Code Glue
24+
**Stable production releases**
25+
- "Thoroughly tested"
26+
- Recommended for production use
27+
- Pulls from `ghcr.io/digital-alchemy-ts/code-glue:latest`
28+
29+
#### Code Glue (Dev)
30+
**Development builds for testing**
31+
- Latest features and bug fixes
32+
- May (will) be unstable and/or ugly.
33+
- Pulls from `ghcr.io/digital-alchemy-ts/code-glue:dev`
34+
- Can run alongside production version with its own DB.
2035

2136
## 🏗️ Developer Setup
2237

@@ -83,7 +98,7 @@ docker compose up -d
8398
6. Migrate the database:
8499

85100
```bash
86-
yarn server:db:migrate
101+
yarn workspace @code-glue/server db:migrate
87102
```
88103

89104
7. Start the client and server
@@ -92,41 +107,19 @@ yarn server:db:migrate
92107
yarn dev
93108
```
94109

95-
Access the application at `http://localhost:8081`
96-
Access swagger: `http://localhost:3789/swagger/`
97-
98-
### Testing in Home Assistant
99-
100-
To test the addon in a real Home Assistant environment:
101-
102-
1. In your Home Assistant instance:
103-
- Add the addon repository: `https://github.com/Digital-Alchemy-TS/code-glue-addon`
104-
- Install "Code Glue (Dev)" from the addon store
105-
- This version won't conflict with the production addon
106-
107-
2. To deploy changes:
108-
```bash
109-
# Make your changes and commit them
110-
git commit -am "Your changes"
111-
git push
112-
# GitHub Actions will build and push to ghcr.io/digital-alchemy-ts/code-glue:dev
113-
# Restart the addon in HA to pull the new image
114-
```
115-
116-
The dev addon:
117-
- Has a different slug (`code_glue_dev`) so it runs alongside production
118-
- Uses its own database (separate from production)
119-
- Pulls from `ghcr.io/digital-alchemy-ts/code-glue:dev`
110+
Frontend: `http://localhost:3000`
111+
Swagger: `http://localhost:3789/swagger/`
120112

121113
### 🎛️ General Commands
122114

123-
#### Server
124-
125-
| Command | Notes |
126-
| -------------------------------------------------- | ------------------------------------- |
127-
| `yarn server:start` / `yarn server:start:hot` | Start the dev server |
128-
| `yarn server:lint` / `yarn server:lint --fix` | Run `eslint` |
129-
| `yarn server:test` / `yarn server:test --coverage` | Run tests |
130-
| `yarn server:build` | Verify there is no build issues |
131-
| -------------------------------------------------- | ------------------------------------- |
132-
| `yarn dev` | Run the server and client in dev mode |
115+
| Command | Notes |
116+
| -------------- | ------------------------------------------ |
117+
| `yarn dev` | Start all workspaces in dev (`start` script) |
118+
| `yarn build` | Build all workspaces |
119+
| `yarn lint` | Lint all workspaces |
120+
| `yarn format` | Format all workspaces |
121+
| `yarn test` | Run tests across workspaces |
122+
| `yarn typecheck` | Type check all workspaces |
123+
124+
[repository-badge]: https://img.shields.io/badge/Add%20repository%20to%20my-Home%20Assistant-41BDF5?logo=home-assistant&style=for-the-badge
125+
[repository-url]: https://my.home-assistant.io/redirect/supervisor_add_addon_repository/?repository_url=https%3A%2F%2Fgithub.com%2FDigital-Alchemy-TS%2Fcode-glue

addon-dev/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Code Glue (Dev)
2+
3+
**Development builds** of Code Glue for testing new features.
4+
5+
## ⚠️ Warning
6+
7+
This is the **development version** with latest features and bug fixes. It may be unstable.
8+
9+
- Use for testing new features
10+
- May have bugs or breaking changes
11+
- Runs alongside production version (different slug)
12+
13+
## Installation
14+
15+
1. Add this repository to Home Assistant:
16+
```
17+
https://github.com/Digital-Alchemy-TS/code-glue-addon
18+
```
19+
20+
2. Install "Code Glue (Dev)" from the Add-on Store
21+
3. Start the add-on
22+
4. Access via the sidebar
23+
24+
## Switching Between Versions
25+
26+
Both production and dev versions can be installed simultaneously. They use separate:
27+
- Database files
28+
- Port numbers
29+
- Panel icons
30+
31+
## Documentation
32+
33+
Full documentation available at: https://github.com/Digital-Alchemy-TS/code-glue
34+
35+
## Support
36+
37+
- GitHub Issues: https://github.com/Digital-Alchemy-TS/code-glue/issues
38+
- Documentation: https://github.com/Digital-Alchemy-TS/code-glue

addon-dev/config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Code Glue (Dev)
2+
version: "26.1.0"
3+
slug: code_glue_dev
4+
description: Built-in IDE to write automations and create entities in TypeScript 🚧 Development build 🚧
5+
image: ghcr.io/digital-alchemy-ts/code-glue
6+
arch:
7+
- aarch64
8+
- amd64
9+
url: https://github.com/Digital-Alchemy-TS/code-glue
10+
init: false
11+
homeassistant_api: true
12+
hassio_api: true
13+
ingress: true
14+
ingress_port: 3789
15+
panel_admin: true
16+
panel_icon: mdi:application-braces-outline
17+
panel_title: Code Glue (Dev)
18+
ports:
19+
80/tcp: 3790
20+
ports_description:
21+
80/tcp: Web interface
22+
watchdog: "http://[HOST]:3789/api/v1/health"
23+
backup_exclude:
24+
- "node_modules"

addon-dev/icon.png

86 KB
Loading

addon-dev/logo.png

223 KB
Loading

addon/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Code Glue
2+
3+
Write Automations and create entities in TypeScript using Digital Alchemy.
4+
5+
## Features
6+
7+
- 🎯 **TypeScript-First**: Write type-safe automations and entities
8+
- 🔧 **Embedded IDE**: Built-in code editor for quick changes
9+
- 🏠 **Home Assistant Integration**: Full access to HA APIs
10+
- 📦 **Digital Alchemy Framework**: Powerful SDK for HA development
11+
12+
## Installation
13+
14+
1. Add this repository to Home Assistant:
15+
```
16+
https://github.com/Digital-Alchemy-TS/code-glue-addon
17+
```
18+
19+
2. Install "Code Glue" from the Add-on Store
20+
3. Start the add-on
21+
4. Access via the sidebar
22+
23+
## Documentation
24+
25+
Full documentation available at: https://github.com/Digital-Alchemy-TS/code-glue
26+
27+
## Support
28+
29+
- GitHub Issues: https://github.com/Digital-Alchemy-TS/code-glue/issues
30+
- Documentation: https://github.com/Digital-Alchemy-TS/code-glue

0 commit comments

Comments
 (0)