-
-
Notifications
You must be signed in to change notification settings - Fork 194
149 lines (135 loc) · 5.87 KB
/
oci-repush.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# RaspberryMatic workflow to manually repush docker image/release
# yamllint disable rule:truthy
---
name: Release Build (OCI+Docker repush)
on:
workflow_dispatch:
inputs:
release_tag:
description: 'Release tag (X.Y.Z.YYYMMMDD) to repush'
required: true
default: ""
# default read-only permission
permissions:
contents: read
jobs:
##########################################
# OCI/Docker build and registry push step
oci-multiarch-build-push:
permissions:
contents: write # ncipollo/release-action
packages: write # docker/build-push-action
name: OCI/Docker Build+Push (repush)
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Environment
run: |
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
echo "BUILD_DATETIME=$(date -u +'%FT%T.%3NZ')" >> $GITHUB_ENV
# download OCI platform release assets
- uses: robinraju/[email protected]
with:
tag: ${{ github.event.inputs.release_tag }}
fileName: "RaspberryMatic-*-oci_*.tgz"
# extract all OCI assets
- name: Extract OCI artifacts
run: |
rm -rf oci_build
mkdir -p oci_build
cd oci_build || exit 1
for f in ../RaspberryMatic-${{ github.event.inputs.release_tag }}-oci_*.tgz; do
echo "extracting ${f}..."
DIR=$(basename "${f}" .tgz)
mkdir -p "${DIR}"
tar -C "${DIR}" -xf "${f}"
LAYER=$(jq -r '.[0].Layers[0]' "${DIR}/manifest.json")
mv -f "${DIR}/${LAYER}" "./${DIR}.tar"
rm -rf "${DIR}" "${f}"*
done
- name: Build OCI tags
shell: bash
run: |
BASE_TAG="ghcr.io/${{ github.repository_owner }}/raspberrymatic"
UNIQUE_TAG="${BASE_TAG}:${{ github.event.inputs.release_tag }}"
BRANCH="${GITHUB_REF##*/}"
if [[ ${BRANCH} == 'master' ]]; then
BRANCH_TAG="${BASE_TAG}:latest"
else
BRANCH_TAG="${BASE_TAG}:latest-${BRANCH}"
fi
echo "unique_tag=${UNIQUE_TAG}" >> $GITHUB_OUTPUT
echo "branch_tag=${BRANCH_TAG}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]
with:
install: true
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
- name: Extract docker metadata
id: meta
uses: docker/[email protected]
with:
images: ghcr.io/${{ github.repository }}
labels: |
org.opencontainers.image.description=Alternative OS for your homematicIP CCU
org.opencontainers.image.vendor=RasperryMatic OpenSource Project
org.opencontainers.image.authors=RaspberryMatic OpenSource Team
org.opencontainers.image.version=${{ env.BUILD_VERSION }}-${{ env.GITHUB_SHA7 }}
org.opencontainers.image.url=https://raspberrymatic.de
org.opencontainers.image.created=${{ env.BUILD_DATETIME }}
annotations: |
org.opencontainers.image.description=Alternative OS for your homematicIP CCU
org.opencontainers.image.vendor=RasperryMatic OpenSource Project
org.opencontainers.image.authors=RaspberryMatic OpenSource Team
org.opencontainers.image.version=${{ env.BUILD_VERSION }}-${{ env.GITHUB_SHA7 }}
org.opencontainers.image.url=https://raspberrymatic.de
org.opencontainers.image.created=${{ env.BUILD_DATETIME }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
- name: Build and push container image
uses: docker/[email protected]
id: docker_build
with:
context: oci_build
file: buildroot-external/board/oci/Dockerfile
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: true
build-args: |
tar_prefix=RaspberryMatic-${{ github.event.inputs.release_tag }}-oci_
labels: |
org.opencontainers.image.title=RaspberryMatic
org.opencontainers.image.description=Alternative OS for your homematicIP CCU
org.opencontainers.image.vendor=RasperryMatic OpenSource Project
org.opencontainers.image.authors=RaspberryMatic OpenSource Team
org.opencontainers.image.licenses=Apache-2.0
org.opencontainers.image.url=https://raspberrymatic.de
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}/wiki
org.opencontainers.image.created=${{ env.BUILD_DATETIME }}
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.event.inputs.release_tag }}
io.hass.name=RaspberryMatic CCU
io.hass.description=HomeMatic/homematicIP CCU central based on RaspberryMatic
io.hass.url=https://github.com/${{ github.repository }}/tree/master/home-assistant-addon
io.hass.version=${{ github.event.inputs.release_tag }}
io.hass.type=addon
io.hass.arch=armv7|aarch64|amd64
tags: |
${{ steps.extract_branch.outputs.unique_tag }}
${{ steps.extract_branch.outputs.branch_tag }}
annotations: |
${{ steps.meta.outputs.annotations }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Cleanup oci_build dir
run: |
rm -rf oci_build