-
Notifications
You must be signed in to change notification settings - Fork 14
130 lines (123 loc) · 4.3 KB
/
dsmr-datalogger.yml
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
name: DSMR Datalogger
# Controls when the workflow will run
on:
workflow_dispatch:
push:
branches:
- 'master'
- 'logger-1.2.0'
tags:
- 'v*.*.*'
paths:
- 'dsmr_datalogger/Dockerfile'
- 'dsmr_datalogger/rootfs/**'
- '.github/workflows/dsmr-datalogger.yml'
- 'dsmr_datalogger/config.json'
jobs:
dsmr-datalogger:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
strategy:
matrix:
include:
# AMD64
- DOCKER_TAG_SUFFIX: amd64
S6_ARCH: amd64
BASE_IMAGE: ghcr.io/home-assistant/amd64-base-python:3.13-alpine3.21
PLATFORMS: linux/amd64
QEMU_ARCH: x86_64
# ARM32V6
- DOCKER_TAG_SUFFIX: armhf
S6_ARCH: armhf
BASE_IMAGE: ghcr.io/home-assistant/armhf-base-python:3.13-alpine3.21
PLATFORMS: linux/arm/v6
QEMU_ARCH: arm
# ARM32V7
- DOCKER_TAG_SUFFIX: armv7
S6_ARCH: armv7
BASE_IMAGE: ghcr.io/home-assistant/armv7-base-python:3.13-alpine3.21
PLATFORMS: linux/arm/v7
QEMU_ARCH: arm
# ARM64V8
- DOCKER_TAG_SUFFIX: aarch64
S6_ARCH: aarch64
BASE_IMAGE: ghcr.io/home-assistant/aarch64-base-python:3.13-alpine3.21
PLATFORMS: linux/arm64
QEMU_ARCH: aarch64
# i386
- DOCKER_TAG_SUFFIX: i386
S6_ARCH: i386
BASE_IMAGE: ghcr.io/home-assistant/i386-base-python:3.13-alpine3.21
PLATFORMS: linux/i386
QEMU_ARCH: i386
steps:
# Get the repository's code
- name: Checkout
uses: actions/checkout@v4
# https://github.com/docker/setup-qemu-action
- name: Get the version from config.json
id: data
run: |
version=$(jq --raw-output '.version' ./dsmr_datalogger/config.json)
echo "HA_RELEASE=$version" >> "$GITHUB_OUTPUT"
- name: DSMR addon release
env:
HA_RELEASE: ${{ steps.data.outputs.HA_RELEASE }}
run: echo "$HA_RELEASE"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta # you'll use this in the next step
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
sanderdw/ha-dsmr-datalogger-${{ matrix.DOCKER_TAG_SUFFIX }}
ghcr.io/${{ github.repository }}/ha-dsmr-datalogger-${{ matrix.DOCKER_TAG_SUFFIX }}
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=${{ steps.data.outputs.HA_RELEASE }}
- name: Build and push
id: push
uses: docker/build-push-action@v5
with:
context: ./dsmr_datalogger
platforms: ${{ matrix.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_FROM=${{matrix.BASE_IMAGE}}
HA_RELEASE=${{ steps.data.outputs.HA_RELEASE }}
BUILD_ARCH=${{matrix.S6_ARCH}}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/${{ github.repository }}/ha-dsmr-datalogger-${{ matrix.DOCKER_TAG_SUFFIX }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true