-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (129 loc) · 4.52 KB
/
Copy pathrelease.yml
File metadata and controls
145 lines (129 loc) · 4.52 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
name: Release
# Триггер: push тега v* (например, v0.1.0). Создаёт GitHub Release и пушит
# multi-arch Docker-образ в GitHub Container Registry (ghcr.io).
on:
push:
tags:
- 'v*'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=raw,value=latest,enable={{is_default_branch}}
# Multi-arch image для Docker Compose / standalone-инсталляций.
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Архитектурно-разделённые образы для HA Add-on. Supervisor подставляет
# {arch} в image name из config.yaml — поэтому нужны отдельные тэги
# ghcr.io/ivkaiv/amd64-homeglance и ghcr.io/ivkaiv/aarch64-homeglance.
- id: addon-meta-amd64
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/amd64-homeglance
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.addon-meta-amd64.outputs.tags }}
labels: ${{ steps.addon-meta-amd64.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- id: addon-meta-aarch64
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/aarch64-homeglance
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v5
with:
context: .
platforms: linux/arm64
push: true
tags: ${{ steps.addon-meta-aarch64.outputs.tags }}
labels: ${{ steps.addon-meta-aarch64.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
release:
runs-on: ubuntu-latest
needs: docker
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract changelog for tag
id: changelog
run: |
TAG="${GITHUB_REF#refs/tags/}"
VERSION="${TAG#v}"
# Достаём секцию релиза из CHANGELOG.md между [VERSION] и следующим заголовком версии.
NOTES=$(awk -v v="$VERSION" '
$0 ~ "^## \\[" v "\\]" { found=1; next }
found && /^## \[/ { exit }
found { print }
' CHANGELOG.md)
{
echo 'notes<<EOF'
echo "${NOTES:-Release $TAG}"
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.notes }}
draft: false
prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }}
hacs-asset:
runs-on: ubuntu-latest
needs: release
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Attach HACS plugin to release
run: |
TAG="${GITHUB_REF#refs/tags/}"
gh release upload "$TAG" \
homeglance.js \
hacs.json \
--clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}