-
-
Notifications
You must be signed in to change notification settings - Fork 33
124 lines (110 loc) · 4.09 KB
/
build_release.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
name: "DSMR: Build Docker images"
on:
# push:
# branches:
# - develop
# - main
# paths-ignore:
# - "**.md"
# pull_request:
# branches:
# - develop
# - main
# types:
# - closed
# paths-ignore:
# - "**.md"
workflow_dispatch:
concurrency:
group: docker-build
cancel-in-progress: true
env:
DOCKER_TARGET_REPO: xirixiz/dsmr-reader-docker
DOCKERFILE: Dockerfile
DOCKER_TARGET_RELEASE: 2024.02.21
jobs:
################################################
## JOB: BUILD_RELEASE
################################################
build_release:
runs-on: ubuntu-latest
steps:
################################################
## GENERAL
################################################
- name: "🚀 GitHub - Checkout repository"
uses: actions/checkout@v3
- name: "🚀 GitHub - Get Branch / Tag Name"
id: get_branch
run: |
export RELEASE_NAME=$(if [[ "${GITHUB_REF}" =~ "refs/tags/" ]]; \
then echo ${GITHUB_REF/refs\/tags\//}; \
else echo ${GITHUB_REF/refs\/heads\//}; fi)
echo "${RELEASE_NAME}"
echo "NAME=${RELEASE_NAME}" >>$GITHUB_OUTPUT
- name: "🚀 GitHub - Get Tag"
id: get_tag
run: |
export TARGET_IMAGE_TAG=$(if [ "${{ steps.get_branch.outputs.name }}" = "main" ]; \
then echo "${{ matrix.DOCKER_TAG_SUFFIX }}"; \
else echo "${{ matrix.DOCKER_TAG_SUFFIX }}-${{ steps.get_branch.outputs.name }}"; \
fi;)
echo "${TARGET_IMAGE_TAG}"
echo "NAME=${TARGET_IMAGE_TAG}" >>$GITHUB_OUTPUT
################################################
## QEMU
################################################
- name: "⚙️ QEMU - Set up QEMU"
uses: docker/setup-qemu-action@v2
################################################
## DSMR
################################################
- name: "⚙️ DSMR - Determine version"
id: dsmr_version
shell: bash
run: |
URL='https://api.github.com/repos/dsmrreader/dsmr-reader/releases/latest'
# TODO: Add tag release support
VERSION=$(curl -SskLf "${URL}" | jq -r '.tag_name')
DOWNLOAD_URL=$(curl -SskLf "${URL}" | jq -r '.tarball_url')
# VERSION="5.0.0"
VERSION=${VERSION#"v"}
echo "version=${VERSION}" >>$GITHUB_OUTPUT
################################################
## Docker
################################################
- name: "⚙️ Docker - Set up Docker Buildx"
uses: docker/setup-buildx-action@v2
- name: "🔓 Docker - Login"
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: "🔓 Docker - Login to GHCR"
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "⚙️ Docker - Set up metadata"
id: meta
uses: docker/metadata-action@v4
with:
tags: |
type=raw,value=${{ steps.dsmr_version.outputs.version }}-${{ env.DOCKER_TARGET_RELEASE }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=raw,value=development,enable=${{ github.ref != format('refs/heads/{0}', 'main') }}
images: |
${{ env.DOCKER_TARGET_REPO }}
ghcr.io/${{ env.DOCKER_TARGET_REPO }}
- name: "🚀 Docker - Build"
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |-
DSMR_VERSION=${{ steps.dsmr_version.outputs.version }}
DOCKER_TARGET_RELEASE=${{ env.DOCKER_TARGET_RELEASE }}