Skip to content

Commit 3aa3e73

Browse files
authored
Add Github Actions (#156)
Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent e1195c9 commit 3aa3e73

6 files changed

Lines changed: 433 additions & 15 deletions

File tree

.azure/build-pipeline.yaml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ stages:
3232
artifactRunVersion: ''
3333
artifactRunId: ''
3434
architectures: ['amd64', 'arm64', 's390x', 'ppc64le']
35-
- stage: container_publish
36-
displayName: Publish Container
37-
dependsOn:
38-
- container_build
39-
condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
40-
jobs:
41-
- template: 'templates/jobs/push_container.yaml'
42-
parameters:
43-
dockerTag: 'latest'
44-
artifactSource: 'current'
45-
artifactProject: 'strimzi'
46-
artifactPipeline: ''
47-
artifactRunVersion: ''
48-
artifactRunId: ''
49-
architectures: ['amd64', 'arm64', 's390x', 'ppc64le']
35+
# Push is now done by GitHub Actions
36+
# - stage: container_publish
37+
# displayName: Publish Container
38+
# dependsOn:
39+
# - container_build
40+
# condition: and(succeeded(), eq(variables['build.sourceBranch'], 'refs/heads/main'))
41+
# jobs:
42+
# - template: 'templates/jobs/push_container.yaml'
43+
# parameters:
44+
# dockerTag: 'latest'
45+
# artifactSource: 'current'
46+
# artifactProject: 'strimzi'
47+
# artifactPipeline: ''
48+
# artifactRunVersion: ''
49+
# artifactRunId: ''
50+
# architectures: ['amd64', 'arm64', 's390x', 'ppc64le']
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: "Build Client Examples Binaries"
2+
description: "Build and archive client examples binaries"
3+
4+
inputs:
5+
javaVersion:
6+
description: "Java version"
7+
required: false
8+
default: "17"
9+
runnerArch:
10+
description: "Architecture of GitHub runner"
11+
required: false
12+
default: "amd64"
13+
mainBuild:
14+
description: "Whether this is the main build"
15+
required: false
16+
default: "false"
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Setup Java
22+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/setup-java@main
23+
with:
24+
javaVersion: ${{ inputs.javaVersion }}
25+
26+
- name: Setup Yq
27+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/install-yq@main
28+
29+
- name: Restore Maven cache
30+
uses: actions/cache/restore@v5
31+
with:
32+
path: ~/.m2/repository
33+
key: maven-${{ hashFiles('**/pom.xml') }}
34+
restore-keys: |
35+
maven-
36+
37+
- name: Build Java code
38+
shell: bash
39+
run: make java_install
40+
env:
41+
MVN_ARGS: "-DskipTests -e -V -B"
42+
43+
- name: Run Spotbugs
44+
shell: bash
45+
run: make spotbugs
46+
env:
47+
MVN_ARGS: "-e -V -B"
48+
49+
- name: Build & Test Java code
50+
shell: bash
51+
run: mvn verify
52+
env:
53+
MVN_ARGS: "-e -V -B"
54+
55+
- name: Create tarball with binaries
56+
shell: bash
57+
run: |
58+
# Create tarball with all Java module targets
59+
tar -cvpf client-examples-binaries.tar $(find . -type d -print | grep target)
60+
61+
- name: Upload binaries artifact (main build)
62+
if: ${{ inputs.mainBuild == 'true' }}
63+
uses: actions/upload-artifact@v5
64+
with:
65+
name: client-examples-binaries.tar
66+
path: client-examples-binaries.tar
67+
68+
- name: Upload binaries artifact with Java version
69+
uses: actions/upload-artifact@v5
70+
with:
71+
name: client-examples-binaries-java-${{ inputs.javaVersion }}.tar
72+
path: client-examples-binaries.tar
73+
74+
- name: Clean external SNAPSHOT dependencies from Maven repository
75+
if: github.ref == 'refs/heads/main'
76+
shell: bash
77+
run: |
78+
mvn dependency:purge-local-repository \
79+
-DsnapshotsOnly=true \
80+
-DreResolve=false || true
81+
82+
- name: Save Maven cache
83+
if: github.ref == 'refs/heads/main' && inputs.mainBuild == 'true'
84+
uses: actions/cache/save@v5
85+
with:
86+
path: ~/.m2/repository
87+
key: maven-${{ hashFiles('**/pom.xml') }}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: "Build Client Examples Containers"
2+
description: "Build and archive client examples container images"
3+
4+
inputs:
5+
architecture:
6+
description: "Architecture to build (amd64, arm64, s390x, ppc64le)"
7+
required: false
8+
default: "amd64"
9+
runnerArch:
10+
description: "Architecture of GitHub runner"
11+
required: false
12+
default: "amd64"
13+
buildRunId:
14+
description: "Build workflow run ID for artifact download"
15+
required: false
16+
default: ""
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Setup Docker
22+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/install-docker@main
23+
24+
- name: Download binaries from this workflow
25+
if: ${{ inputs.buildRunId == '' }}
26+
uses: actions/download-artifact@v7
27+
with:
28+
name: client-examples-binaries.tar
29+
30+
- name: Download binaries from external build
31+
if: ${{ inputs.buildRunId != '' }}
32+
uses: actions/download-artifact@v7
33+
with:
34+
name: client-examples-binaries.tar
35+
run-id: ${{ inputs.buildRunId }}
36+
github-token: ${{ github.token }}
37+
38+
- name: Untar binaries
39+
shell: bash
40+
run: tar -xvf client-examples-binaries.tar
41+
42+
- name: Build and save containers
43+
shell: bash
44+
run: make docker_build docker_save
45+
env:
46+
DOCKER_BUILDKIT: 1
47+
BUILD_REASON: "IndividualCI"
48+
BRANCH: ${{ github.ref }}
49+
DOCKER_REGISTRY: "quay.io"
50+
DOCKER_ORG: "strimzi-examples"
51+
DOCKER_ARCHITECTURE: ${{ inputs.architecture }}
52+
53+
- name: Create tarball with containers
54+
shell: bash
55+
run: |
56+
tar -cvpf containers-${{ inputs.architecture }}.tar *-${{ inputs.architecture }}.tar.gz
57+
58+
- name: Upload container artifact
59+
uses: actions/upload-artifact@v5
60+
with:
61+
name: containers-${{ inputs.architecture }}.tar
62+
path: containers-${{ inputs.architecture }}.tar
63+
64+
- name: List built images
65+
if: ${{ always() }}
66+
shell: bash
67+
run: docker images -a
68+
69+
# Made with Bob
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: "Push Client Examples Containers"
2+
description: "Push Client Examples container images with signing and SBOM"
3+
4+
inputs:
5+
architectures:
6+
description: "Comma-separated list of architectures (e.g., 'amd64,arm64,s390x,ppc64le')"
7+
required: true
8+
runnerArch:
9+
description: "Runner architecture (amd64, arm64)"
10+
required: false
11+
default: "amd64"
12+
quayUser:
13+
description: "Quay.io username"
14+
required: true
15+
quayPass:
16+
description: "Quay.io password"
17+
required: true
18+
buildRunId:
19+
description: "Build workflow run ID for artifact download"
20+
required: false
21+
default: ""
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Install Syft
27+
shell: bash
28+
run: |
29+
ARCH="${{ inputs.runnerArch }}"
30+
VERSION="0.90.0"
31+
wget https://github.com/anchore/syft/releases/download/v${VERSION}/syft_${VERSION}_linux_${ARCH}.tar.gz -O syft.tar.gz
32+
tar xf syft.tar.gz -C /tmp
33+
chmod +x /tmp/syft
34+
sudo mv /tmp/syft /usr/bin
35+
36+
- name: Install Cosign
37+
uses: sigstore/cosign-installer@v4.0.0
38+
39+
- name: Setup Docker
40+
uses: strimzi/strimzi-kafka-operator/.github/actions/dependencies/install-docker@main
41+
42+
- name: Download container artifacts from external build
43+
if: ${{ inputs.buildRunId != '' }}
44+
uses: actions/download-artifact@v7
45+
with:
46+
pattern: containers-*
47+
path: ./
48+
merge-multiple: true
49+
run-id: ${{ inputs.buildRunId }}
50+
github-token: ${{ github.token }}
51+
52+
- name: Download container artifacts from this workflow
53+
if: ${{ inputs.buildRunId == '' }}
54+
uses: actions/download-artifact@v7
55+
with:
56+
pattern: containers-*
57+
path: ./
58+
merge-multiple: true
59+
60+
- name: Extract container archives
61+
shell: bash
62+
run: |
63+
IFS=',' read -ra ARCH_ARRAY <<< "${{ inputs.architectures }}"
64+
for arch in "${ARCH_ARRAY[@]}"; do
65+
echo "Extracting containers-${arch}.tar"
66+
tar -xvf "containers-${arch}.tar"
67+
rm "containers-${arch}.tar"
68+
done
69+
70+
- name: Login to container registry
71+
shell: bash
72+
run: docker login -u ${{ inputs.quayUser }} -p ${{ inputs.quayPass }} ${{ env.DOCKER_REGISTRY }}
73+
74+
- name: Delete existing container manifests
75+
shell: bash
76+
run: make docker_delete_manifest
77+
env:
78+
BUILD_REASON: "IndividualCI"
79+
BRANCH: ${{ github.ref }}
80+
81+
- name: Push containers and create manifests
82+
shell: bash
83+
run: |
84+
IFS=',' read -ra ARCH_ARRAY <<< "${{ inputs.architectures }}"
85+
for arch in "${ARCH_ARRAY[@]}"; do
86+
echo "Processing architecture: ${arch}"
87+
export DOCKER_ARCHITECTURE="${arch}"
88+
make docker_load docker_tag docker_push docker_amend_manifest docker_delete_archive
89+
done
90+
env:
91+
BUILD_REASON: "IndividualCI"
92+
BRANCH: ${{ github.ref }}
93+
94+
- name: Push container manifests
95+
shell: bash
96+
run: make docker_push_manifest
97+
env:
98+
BUILD_REASON: "IndividualCI"
99+
BRANCH: ${{ github.ref }}
100+
101+
- name: Sign container manifests
102+
shell: bash
103+
run: make docker_gha_sign_manifest
104+
env:
105+
BUILD_REASON: "IndividualCI"
106+
BRANCH: ${{ github.ref }}
107+
BUILD_ID: ${{ github.run_number }}
108+
BUILD_COMMIT: ${{ github.sha }}
109+
110+
- name: Generate and sign SBOMs
111+
shell: bash
112+
run: |
113+
IFS=',' read -ra ARCH_ARRAY <<< "${{ inputs.architectures }}"
114+
for arch in "${ARCH_ARRAY[@]}"; do
115+
echo "Generating SBOM for architecture: ${arch}"
116+
export DOCKER_ARCHITECTURE="${arch}"
117+
make docker_gha_sbom
118+
done
119+
env:
120+
BUILD_REASON: "IndividualCI"
121+
BRANCH: ${{ github.ref }}
122+
123+
- name: Create SBOM archive
124+
shell: bash
125+
run: tar -z -C ./sbom/ -cvpf sbom.tar.gz ./
126+
127+
- name: Upload SBOM artifact
128+
uses: actions/upload-artifact@v5
129+
with:
130+
name: SBOMs-${{ env.DOCKER_TAG }}
131+
path: sbom.tar.gz
132+
133+
- name: Push SBOMs to registry
134+
if: ${{ startsWith(github.ref, 'refs/heads/release-') }}
135+
shell: bash
136+
run: |
137+
IFS=',' read -ra ARCH_ARRAY <<< "${{ inputs.architectures }}"
138+
for arch in "${ARCH_ARRAY[@]}"; do
139+
echo "Pushing SBOM for architecture: ${arch}"
140+
export DOCKER_ARCHITECTURE="${arch}"
141+
make docker_gha_push_sbom
142+
done
143+
env:
144+
BUILD_REASON: "IndividualCI"
145+
BRANCH: ${{ github.ref }}
146+
BUILD_ID: ${{ github.run_number }}
147+
BUILD_COMMIT: ${{ github.sha }}

0 commit comments

Comments
 (0)