Skip to content

Commit cace5c0

Browse files
committed
Init work on actions extraction
Signed-off-by: Jakub Stejskal <xstejs24@gmail.com>
1 parent bfc38b7 commit cace5c0

32 files changed

Lines changed: 2602 additions & 0 deletions

File tree

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: "Build Java Binaries"
2+
description: "Build and test Java binaries using standard Makefile targets"
3+
4+
inputs:
5+
javaVersion:
6+
description: "Java version"
7+
required: false
8+
default: "17"
9+
mainBuild:
10+
description: "Whether this is the main build (true) or a test build (false)"
11+
required: false
12+
default: "true"
13+
artifactName:
14+
description: "Name for the uploaded artifact"
15+
required: false
16+
default: "binaries.tar"
17+
runnerArch:
18+
description: "Runner architecture (amd64, arm64)"
19+
required: false
20+
default: "amd64"
21+
22+
runs:
23+
using: "composite"
24+
steps:
25+
- name: Debug action_path
26+
shell: bash
27+
run: |
28+
echo "github.action_path = ${{ github.action_path }}"
29+
ls -la ${{ github.action_path }}
30+
ls -la .github/actions/build/ || echo "Path doesn't exist"
31+
ls -la github-actions/.github/actions/build/ || echo "Path doesn't exist"
32+
ls -la ${{ github.action_path }}/../../dependencies/ || echo "Path doesn't exist"
33+
34+
- name: Setup Java and Maven
35+
uses: ${{ github.action_path }}/../../dependencies/setup-java
36+
with:
37+
javaVersion: ${{ inputs.javaVersion }}
38+
39+
- name: Restore Maven cache
40+
uses: actions/cache/restore@v5
41+
with:
42+
path: ~/.m2/repository
43+
key: maven-${{ hashFiles('**/pom.xml') }}
44+
restore-keys: |
45+
maven-
46+
47+
- name: Install yq
48+
uses: ${{ github.action_path }}/../../dependencies/install-yq
49+
with:
50+
architecture: ${{ inputs.runnerArch }}
51+
52+
- name: Install Shellcheck
53+
uses: ${{ github.action_path }}/../../dependencies/install-shellcheck
54+
with:
55+
architecture: ${{ inputs.runnerArch }}
56+
57+
- name: Install Helm
58+
uses: ${{ github.action_path }}/../../dependencies/install-helm
59+
60+
- name: Build binaries
61+
shell: bash
62+
run: make java_install
63+
env:
64+
MVN_ARGS: '-B -DskipTests'
65+
66+
- name: Run SpotBugs
67+
shell: bash
68+
run: make spotbugs
69+
70+
- name: Run tests and verification
71+
shell: bash
72+
run: make java_verify
73+
74+
- name: Save Maven cache
75+
if: ${{ inputs.mainBuild == 'true' }}
76+
uses: actions/cache/save@v5
77+
with:
78+
path: ~/.m2/repository
79+
key: maven-${{ hashFiles('**/pom.xml') }}
80+
81+
- name: Create artifact tarball
82+
if: ${{ inputs.mainBuild == 'true' }}
83+
shell: bash
84+
run: |
85+
# Archive build artifacts preserving directory structure for multi-module projects
86+
# Includes:
87+
# - All target/ directories (contains JARs, POMs, and other build outputs)
88+
# Excludes:
89+
# - Test outputs that aren't needed for deployment
90+
91+
tar -cvpf ${{ inputs.artifactName }} \
92+
--exclude='**/surefire-reports' \
93+
--exclude='**/test-classes' \
94+
$(find . -type d -name "target")
95+
96+
- name: Upload artifact
97+
if: ${{ inputs.mainBuild == 'true' }}
98+
uses: actions/upload-artifact@v5
99+
with:
100+
name: ${{ inputs.artifactName }}.tar
101+
path: ${{ inputs.artifactName }}
102+
retention-days: 7
103+
104+
- name: Upload artifact with Java suffix
105+
uses: actions/upload-artifact@v5
106+
with:
107+
name: ${{ inputs.artifactName }}-java-${{ inputs.javaVersion }}.tar
108+
path: ${{ inputs.artifactName }}
109+
retention-days: 7
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: "Build images"
2+
description: "Build and archive images"
3+
4+
inputs:
5+
architecture:
6+
description: "Architecture of images"
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+
containerRegistry:
18+
description: "Container registry (e.g., quay.io, ghcr.io)"
19+
required: false
20+
default: "quay.io"
21+
containerOrg:
22+
description: "Container organization/namespace"
23+
required: false
24+
default: "strimzi"
25+
containerTag:
26+
description: "Container image tag"
27+
required: false
28+
default: "latest"
29+
binariesArchiveName:
30+
description: "Name of archive with binaries"
31+
required: true
32+
imagesDir:
33+
description: "Path to directory with images tar balls"
34+
required: true
35+
36+
runs:
37+
using: "composite"
38+
steps:
39+
- name: Install Docker
40+
uses: ./.github/actions/dependencies/install-docker
41+
- name: Install yq
42+
uses: ./.github/actions/dependencies/install-yq
43+
with:
44+
architecture: ${{ inputs.runnerArch }}
45+
- name: Install Shellcheck
46+
uses: ./.github/actions/dependencies/install-shellcheck
47+
with:
48+
architecture: ${{ inputs.runnerArch }}
49+
50+
- name: Download binaries from this workflow
51+
if: ${{ inputs.buildRunId == '' }}
52+
uses: actions/download-artifact@v7
53+
with:
54+
name: ${{ inputs.binariesArchiveName }}
55+
56+
- name: Download binaries from external build
57+
if: ${{ inputs.buildRunId != '' }}
58+
uses: actions/download-artifact@v7
59+
with:
60+
name: ${{ inputs.binariesArchiveName }}
61+
run-id: ${{ inputs.buildRunId }}
62+
github-token: ${{ github.token }}
63+
64+
- name: "Untar binaries archive"
65+
shell: bash
66+
run: tar -xvf ${{ inputs.binariesArchiveName }}
67+
68+
- name: Build images
69+
shell: bash
70+
run: |
71+
make docker_build docker_save
72+
env:
73+
MVN_ARGS: '-B -DskipTests -Dmaven.javadoc.skip=true'
74+
DOCKER_ARCHITECTURE: ${{ inputs.architecture }}
75+
DOCKER_BUILDKIT: 1
76+
DOCKER_REGISTRY: ${{ inputs.containerRegistry }}
77+
DOCKER_ORG: ${{ inputs.containerOrg }}
78+
DOCKER_TAG: ${{ inputs.containerTag }}
79+
80+
- name: Create tarball with images
81+
shell: bash
82+
run: "tar -cvpf containers-${{ inputs.architecture }}.tar ${{ inputs.imagesDir }}"
83+
84+
- name: Upload containers artifact
85+
uses: actions/upload-artifact@v5
86+
with:
87+
name: containers-${{ inputs.architecture }}.tar
88+
path: containers-${{ inputs.architecture }}.tar
89+
90+
- name: List built images
91+
if: ${{ always() }}
92+
shell: bash
93+
run: |
94+
docker images -a
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: "Deploy Java Artifacts"
2+
description: "Deploys Java artifacts to Maven Central"
3+
4+
inputs:
5+
javaVersion:
6+
description: "Java version"
7+
required: false
8+
default: "17"
9+
settingsPath:
10+
description: "Path to mvn settings file"
11+
required: true
12+
projects:
13+
description: "Maven projects to be uploaded"
14+
required: true
15+
artifactName:
16+
description: "Name of the artifact with binaries (if needs to be downloaded)"
17+
required: false
18+
default: ""
19+
runnerArch:
20+
description: "Runner architecture (amd64, arm64)"
21+
required: false
22+
default: "amd64"
23+
gpgPassphrase:
24+
description: "GPG passphrase for signing"
25+
required: true
26+
gpgSigningKey:
27+
description: "GPG signing key"
28+
required: true
29+
centralUsername:
30+
description: "Maven Central username"
31+
required: true
32+
centralPassword:
33+
description: "Maven Central password"
34+
required: true
35+
36+
runs:
37+
using: "composite"
38+
steps:
39+
# We uses default Java and Maven versions defined in the action
40+
# To change Java and Maven Version change them directly in the action
41+
- name: Setup Java and Maven
42+
uses: ${{ github.action_path }}/../../dependencies/setup-java
43+
with:
44+
javaVersion: ${{ inputs.javaVersion }}
45+
46+
- name: Restore Maven cache
47+
uses: actions/cache/restore@v5
48+
with:
49+
path: ~/.m2/repository
50+
key: maven-${{ hashFiles('**/pom.xml') }}
51+
restore-keys: |
52+
maven-
53+
54+
- name: Install yq
55+
uses: ${{ github.action_path }}/../../dependencies/install-yq
56+
with:
57+
architecture: ${{ inputs.runnerArch }}
58+
59+
- name: Download binaries artifact
60+
if: ${{ inputs.artifactName != '' }}
61+
uses: actions/download-artifact@v7
62+
with:
63+
name: ${{ inputs.artifactName }}
64+
path: ./
65+
66+
- name: Extract binaries artifact
67+
if: ${{ inputs.artifactName != '' }}
68+
shell: bash
69+
run: |
70+
# Extract the tarball preserving directory structure
71+
# This restores:
72+
# - target/ directories with all build outputs
73+
# - Multi-module project structure
74+
tar -xvf ${{ inputs.artifactName }}
75+
76+
# Remove the tarball to clean up
77+
rm ${{ inputs.artifactName }}
78+
79+
# Verify extraction
80+
echo "Extracted structure:"
81+
find . -name "pom.xml" -o -type d -name "target" | head -20
82+
83+
- name: Deploy Java artifacts
84+
shell: bash
85+
run: ${{ github.action_path }}/push-to-central.sh
86+
env:
87+
BUILD_REASON: "IndividualCI"
88+
BRANCH: ${{ github.ref }}
89+
GPG_PASSPHRASE: ${{ inputs.gpgPassphrase }}
90+
GPG_SIGNING_KEY: ${{ inputs.gpgSigningKey }}
91+
CENTRAL_USERNAME: ${{ inputs.centralUsername }}
92+
CENTRAL_PASSWORD: ${{ inputs.centralPassword }}
93+
SETTINGS_PATH: ${{ inputs.settingsPath }}
94+
PROJECTS: ${{ inputs.projects }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
function cleanup() {
5+
rm -rf signing.gpg
6+
gpg --delete-keys
7+
gpg --delete-secret-keys
8+
}
9+
10+
# Run the cleanup on failure / exit
11+
trap cleanup EXIT
12+
13+
export GPG_TTY=$(tty)
14+
echo $GPG_SIGNING_KEY | base64 -d > signing.gpg
15+
gpg --batch --import signing.gpg
16+
17+
# Deploy to Maven Central using already-built artifacts
18+
# Flags explanation:
19+
# -DskipTests: Skip test execution
20+
# -Dmaven.main.skip=true: Skip compilation of main sources (use already compiled)
21+
# -Dmaven.test.skip=true: Skip compilation of test sources
22+
#
23+
# Note: We keep install phase enabled (no -Dmaven.install.skip=true) because:
24+
# - For multi-module projects, install phase is needed to resolve inter-module dependencies
25+
# - Install phase is fast when artifacts are already built (just copies to .m2/repository)
26+
# - It ensures Maven can properly locate all artifacts for deployment
27+
# TODO - double check how it works and alco the comment
28+
GPG_EXECUTABLE=gpg mvn $MVN_ARGS \
29+
-DskipTests \
30+
-Dmaven.main.skip=true \
31+
-Dmaven.test.skip=true \
32+
-Dmaven.install.skip=true \
33+
-s $SETTINGS_PATH \
34+
-pl $PROJECTS \
35+
-P central \
36+
deploy
37+
38+
cleanup

0 commit comments

Comments
 (0)