-
-
Notifications
You must be signed in to change notification settings - Fork 23
122 lines (122 loc) · 5.44 KB
/
release_build_docker.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
name: Docker Release build
on:
workflow_dispatch:
release:
types: [released]
env:
REGISTRY: ghcr.io
jobs:
info:
runs-on: ubuntu-latest
name: Get repository information
outputs:
version: ${{ steps.vars.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: congatudo/Congatudo
fetch-depth: 0
token: ${{ github.token }}
- name: Set up variables
id: vars
run: echo "version=$(git describe --abbrev=0 --tags HEAD)" >> $GITHUB_OUTPUT
matrix:
runs-on: ubuntu-latest
name: Get matrix from json
outputs:
matrix: ${{ steps.vars.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up variables
id: vars
run: echo "matrix=$(jq -c . matrix.json)" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: Build for ${{ matrix.image_name }}
needs: [info, matrix]
strategy:
max-parallel: 2
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
steps:
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/[email protected]
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.image_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ matrix.image_name }}-
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/[email protected]
with:
push: false
load: true
tags: |
${{ env.REGISTRY }}/congatudo/congatudo:${{ matrix.image_name }}-${{ needs.info.outputs.version }}
${{ env.REGISTRY }}/congatudo/congatudo:${{ matrix.image_name }}-latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
build-args: |
"BUILD_FROM=${{ matrix.build_from }}"
"PKG_TARGET=${{ matrix.pkg_target }}"
"PKG_OPTIONS=${{ matrix.pkg_options }}"
- name: Push
run: |
docker push ${{ env.REGISTRY }}/congatudo/congatudo:${{ matrix.image_name }}-${{ needs.info.outputs.version }}
docker push ${{ env.REGISTRY }}/congatudo/congatudo:${{ matrix.image_name }}-latest
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
manifest:
runs-on: ubuntu-latest
name: Create and push manifest
needs: [info, build]
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest
run: |
# TODO: Use matrix here.
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo:alpine-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-amd64-latest
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-armhf-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-armv7-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-aarch64-latest \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-amd64-latest
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo:alpine-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-armv7-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-aarch64-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:alpine-amd64-${{ needs.info.outputs.version }}
docker manifest create ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-armhf-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-armv7-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-aarch64-${{ needs.info.outputs.version }} \
--amend ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-amd64-${{ needs.info.outputs.version }}
- name: Push manifest
run: |
# TODO: Use matrix here.
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo:alpine-latest
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-latest
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo:alpine-${{ needs.info.outputs.version }}
docker manifest push ${{ env.REGISTRY }}/congatudo/congatudo:homeassistant-${{ needs.info.outputs.version }}