-
-
Notifications
You must be signed in to change notification settings - Fork 29
158 lines (135 loc) · 5.82 KB
/
ci.yml
File metadata and controls
158 lines (135 loc) · 5.82 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
156
157
158
name: CI
on:
push:
branches:
- main
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
permissions:
contents: read
id-token: write
env:
REGISTRY: ghcr.io
jobs:
checks:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- name: Update NPM
run: npm install -g npm@latest
- run: npm ci
- run: npm run check:ci
- run: npm run typecheck
- run: npm run build
- run: npm run test:cov
# build container when triggered by release (push on tag)
- name: Log in to the GitHub container registry
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker setup - QEMU
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
uses: docker/setup-qemu-action@v3
- name: Docker setup - Buildx
if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && github.event_name == 'push'
uses: docker/setup-buildx-action@v3
- name: edge - Docker meta
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: docker/metadata-action@v5
id: meta_edge
with:
images: |
ghcr.io/nerivec/zigbee2mqtt-windfront
tags: |
type=edge
labels: |
org.opencontainers.image.authors=Nerivec
org.opencontainers.image.documentation=https://github.com/Nerivec/zigbee2mqtt-windfront/wiki
- name: edge - Docker build and push
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/riscv64,linux/386
tags: ${{ steps.meta_edge.outputs.tags }}
push: true
- name: Docker meta
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/nerivec/zigbee2mqtt-windfront
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
labels: |
org.opencontainers.image.authors=Nerivec
org.opencontainers.image.documentation=https://github.com/Nerivec/zigbee2mqtt-windfront/wiki
- name: Docker build and push
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/riscv64,linux/386
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Publish package to npmjs.org
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
run: npm publish --provenance --access public
- name: Add tarball dist to release assets
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
run: |
mv dist zigbee2mqtt-windfront-${{ github.ref_name }}
tar -czvf zigbee2mqtt-windfront-${{ github.ref_name }}.tar.gz zigbee2mqtt-windfront-${{ github.ref_name }}
gh release upload ${{ github.ref_name }} zigbee2mqtt-windfront-${{ github.ref_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish built-main branch
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
temp_dir=$(mktemp -d)
cp -R dist/. $temp_dir
git switch --orphan built-main
rm -rf ./*
cp -R $temp_dir/* .
git add -A
git config --local user.name 'github-actions[bot]'
git config --local user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "$GITHUB_SHA" || echo 'Nothing to commit'
git push --force --set-upstream origin built-main
- name: Trigger ha-zigbee2mqtt-windfront windfront_edge build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Nerivec/ha-zigbee2mqtt-windfront/actions/workflows/manual-builder.yaml/dispatches \
-d '{"ref":"main","inputs":{"addon_folder":"windfront_edge"}}'
- name: Create ha-zigbee2mqtt-windfront windfront bump version PR
if: startsWith(github.ref, 'refs/tags/') && github.event_name == 'push'
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Nerivec/ha-zigbee2mqtt-windfront/actions/workflows/bump-version.yaml/dispatches \
-d '{"ref":"main","inputs":{"addon_folder":"windfront", "arg_name": "WINDFRONT", "version": "${{ github.ref_name }}", "changelog": "## ${{ github.ref_name }}\n\n- [WindFront release notes](https://github.com/Nerivec/zigbee2mqtt-windfront/releases/tag/${{ github.ref_name }})"}}'