Skip to content

Commit c9de11f

Browse files
committed
Make release action more efficient and inline with other RADAR-base repos
1 parent 7fe527d commit c9de11f

File tree

3 files changed

+119
-198
lines changed

3 files changed

+119
-198
lines changed

.github/workflows/release-fitbit.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

.github/workflows/release-oura.yml

Lines changed: 0 additions & 99 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
REPOSITORY: ${{ github.repository }}
10+
IMAGES: >-
11+
[{
12+
'name': 'kafka-connect-fitbit-source',
13+
'build_file': 'kafka-connect-fitbit-source/Dockerfile',
14+
'authors': 'Pim van Nierop <[email protected]>, Pauline Conde <[email protected]>',
15+
'description': 'RADAR-base Fitbit connector application'
16+
},{
17+
'name': 'kafka-connect-oura-source',
18+
'build_file': 'kafka-connect-oura-source/Dockerfile',
19+
'authors': 'Pauline Conde <[email protected]>, Yatharth Ranjan <[email protected]>',
20+
'description': 'RADAR-base Oura connector application'
21+
}]
22+
23+
jobs:
24+
upload:
25+
runs-on: ubuntu-latest
26+
permissions: write-all
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-java@v4
32+
with:
33+
distribution: temurin
34+
java-version: 17
35+
36+
- name: Setup Gradle
37+
uses: gradle/actions/setup-gradle@v3
38+
39+
- name: Compile code
40+
run: ./gradlew assemble
41+
42+
- name: Upload to GitHub
43+
uses: AButler/[email protected]
44+
with:
45+
files: '*/build/libs/*'
46+
repo-token: ${{ secrets.GITHUB_TOKEN }}
47+
48+
prepare-matrix:
49+
name: Prepare Matrix Output
50+
runs-on: ubuntu-latest
51+
permissions: {}
52+
outputs:
53+
images: ${{ steps.step1.outputs.matrix }}
54+
steps:
55+
- name: Create Matrix Variable
56+
id: step1
57+
run: echo "matrix=${{ env.IMAGES }}" >> $GITHUB_OUTPUT
58+
59+
docker:
60+
needs: prepare-matrix
61+
runs-on: ubuntu-latest
62+
strategy:
63+
matrix:
64+
image: ${{ fromJson(needs.prepare-matrix.outputs.images ) }}
65+
permissions:
66+
contents: read
67+
packages: write
68+
69+
steps:
70+
- uses: actions/checkout@v3
71+
72+
# Setup docker build environment
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v2
75+
76+
- name: Set up Docker Buildx
77+
id: buildx
78+
uses: docker/setup-buildx-action@v2
79+
80+
- name: Login to Container Registry
81+
uses: docker/login-action@v2
82+
with:
83+
registry: ${{ env.REGISTRY }}
84+
username: ${{ github.actor }}
85+
password: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- name: Lowercase image name
88+
run: |
89+
echo "DOCKER_IMAGE=${REGISTRY}/${REPOSITORY,,}/${{ matrix.image.name }}" >>${GITHUB_ENV}
90+
91+
# Add Docker labels and tags
92+
- name: Docker meta
93+
id: docker_meta
94+
uses: docker/metadata-action@v4
95+
with:
96+
images: ${{ env.DOCKER_IMAGE }}
97+
tags: |
98+
type=match,pattern=v(.*),group=1
99+
100+
- name: Build docker and push
101+
uses: docker/build-push-action@v3
102+
with:
103+
context: .
104+
file: ${{ matrix.image.build_file }}
105+
platforms: linux/amd64,linux/arm64
106+
push: true
107+
tags: ${{ steps.docker_meta.outputs.tags }}
108+
labels: |
109+
${{ steps.docker_meta.outputs.labels }}
110+
maintainer=${{ matrix.image.authors }}
111+
org.opencontainers.image.description=${{ matrix.image.description }}
112+
org.opencontainers.image.authors=${{ matrix.image.authors }}
113+
org.opencontainers.image.vendor=RADAR-base
114+
org.opencontainers.image.licenses=Apache-2.0
115+
116+
- name: Inspect docker image
117+
run: |
118+
docker pull ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}
119+
docker image inspect ${{ env.DOCKER_IMAGE }}:${{ steps.docker_meta.outputs.version }}

0 commit comments

Comments
 (0)