-
Notifications
You must be signed in to change notification settings - Fork 202
155 lines (141 loc) · 5.57 KB
/
Copy pathaddon-publish-dev.yml
File metadata and controls
155 lines (141 loc) · 5.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Home Assistant Add-on Publish (Dev)
on:
push:
branches: [master]
paths:
- 'src/**'
- 'homeassistant-addon/**'
- 'homeassistant-addon-dev/**'
- 'pyproject.toml'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_PREFIX: ghcr.io/${{ github.repository }}-addon-dev
# Restrict permissions by default
permissions:
contents: read
# Serialize with every other workflow that pushes to master (this one pushes
# the dev add-on config bump via _update-addon-config.yml): a push landing
# while a release workflow's semantic-release is mid-run aborts that release
# un-retryably ("Upstream branch ... has changed").
concurrency:
group: master-write
cancel-in-progress: false
# queue: max keeps every queued run waiting FIFO. The default single-slot
# queue evicts the OLDER pending run when a new one queues, which could
# silently drop a queued release behind a bot push.
queue: max
jobs:
# Skip if commit is from semantic-release
check-skip:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.check.outputs.should_skip }}
steps:
- name: Check if should skip
id: check
env:
# Use env var to avoid shell interpretation of backticks in commit messages
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
if [[ "$COMMIT_MSG" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || [[ "$COMMIT_MSG" =~ "chore(release)" ]]; then
echo "should_skip=true" >> $GITHUB_OUTPUT
else
echo "should_skip=false" >> $GITHUB_OUTPUT
fi
prepare:
needs: check-skip
if: needs.check-skip.outputs.should_skip != 'true'
runs-on: ubuntu-latest
outputs:
dev_version: ${{ steps.version.outputs.dev_version }}
short_sha: ${{ steps.version.outputs.short_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
# Full history: the dev version number is the commit count.
fetch-depth: 0
- name: Generate dev version
id: version
run: |
BASE_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-7)
# dev N = commit count on master: the same commit produces the SAME
# number in every workflow (PyPI/Docker in publish-dev, the dev
# add-on here), so all surfaces report one dev version. run_number
# was per-workflow, which is how the add-on drifted ~300 builds
# behind the PyPI counter and made version reports incomparable.
# Count origin/master (not HEAD): a workflow_dispatch on an older
# ref would otherwise mint a LOWER number that collides with an
# existing dev release and clobbers it.
DEV_VERSION="${BASE_VERSION}.dev$(git rev-list --count origin/master)"
echo "dev_version=$DEV_VERSION" >> $GITHUB_OUTPUT
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "Dev add-on version: $DEV_VERSION (sha: $SHORT_SHA)"
build-addon-dev:
name: Build Dev Add-on (${{ matrix.arch }})
needs: prepare
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
arch:
- amd64
- aarch64
include:
- arch: amd64
platform: linux/amd64
- arch: aarch64
platform: linux/arm64
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
submodules: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
file: ./homeassistant-addon-dev/Dockerfile
push: true
platforms: ${{ matrix.platform }}
tags: |
${{ env.IMAGE_PREFIX }}-${{ matrix.arch }}:latest
${{ env.IMAGE_PREFIX }}-${{ matrix.arch }}:dev
${{ env.IMAGE_PREFIX }}-${{ matrix.arch }}:${{ needs.prepare.outputs.dev_version }}
labels: |
io.hass.name=Home Assistant MCP Server (Dev)
io.hass.description=Development channel - AI assistant integration via MCP
io.hass.version=${{ needs.prepare.outputs.dev_version }}
io.hass.type=addon
io.hass.arch=${{ matrix.arch }}
cache-from: type=gha,scope=addon-dev-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=addon-dev-${{ matrix.arch }}
build-args: |
BUILD_VERSION=${{ needs.prepare.outputs.dev_version }}
BUILD_ARCH=${{ matrix.arch }}
# Update dev addon config.yaml so HA Supervisor detects new versions
update-addon-dev-config:
needs: [prepare, build-addon-dev]
uses: ./.github/workflows/_update-addon-config.yml
with:
version: ${{ needs.prepare.outputs.dev_version }}
config_path: homeassistant-addon-dev/config.yaml
commit_message_prefix: 'publish dev addon version'
secrets:
RELEASE_APP_ID: ${{ secrets.RELEASE_APP_ID }}
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
permissions:
contents: write