Skip to content

Commit c9ea4cb

Browse files
committed
👷 Update CI script to build native images.
1 parent 4cfa601 commit c9ea4cb

2 files changed

Lines changed: 108 additions & 59 deletions

File tree

.github/workflows/main.yml

Lines changed: 107 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ on:
88
- beta
99

1010
jobs:
11-
build:
12-
name: Build
11+
prepare:
12+
timeout-minutes: 10
1313
runs-on: ubuntu-latest
14-
timeout-minutes: 20
15-
permissions:
16-
contents: write
14+
outputs:
15+
VERSION: ${{ steps.version.outputs.VERSION }}
16+
DOCKER_TAG: ${{ steps.version.outputs.DOCKER_TAG }}
1717
steps:
1818
- name: Code Checkout
1919
uses: actions/checkout@v6
2020

2121
- name: Get release attributes
22+
id: version
2223
run: |
2324
SUFFIX=""
2425
DOCKER_TAG=$GITHUB_REF_NAME
@@ -27,17 +28,16 @@ jobs:
2728
alpha) SUFFIX="A";;
2829
beta) SUFFIX="B";;
2930
esac
30-
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
31+
echo "DOCKER_TAG=$DOCKER_TAG" >> GITHUB_OUTPUT
3132
VERSION=$(grep 'version = ' build.gradle.kts | cut -f 2 -d "\"")$SUFFIX
32-
echo "VERSION=$VERSION" >> $GITHUB_ENV
33+
echo "VERSION=$VERSION" >> GITHUB_OUTPUT
3334
3435
- name: Check if version is used
3536
run: |
36-
URL=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/${{ env.VERSION }}
37-
echo "$URL"
37+
URL=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases/tags/${{ steps.version.outputs.VERSION }}
3838
CODE=$(curl -s -H "Authorization: Bearer ${{ github.token }}" -o /dev/null -w "%{http_code}" "$URL")
3939
if [ "$CODE" != 404 ]; then
40-
echo "Release '$VERSION' already exists. ($CODE)"
40+
echo "Release '${{ steps.version.outputs.VERSION }}' already exists. ($CODE)"
4141
exit 1
4242
fi
4343
@@ -50,16 +50,28 @@ jobs:
5050
- name: Run linter
5151
run: ktlint
5252

53-
- name: Setup Java
54-
uses: actions/setup-java@v5
55-
with:
56-
distribution: 'adopt'
57-
java-version: '21'
53+
build-native:
54+
needs: prepare
55+
timeout-minutes: 40
56+
strategy:
57+
matrix:
58+
include:
59+
- os: ubuntu-latest
60+
arch: amd64
61+
- os: ubuntu-24.04-arm
62+
arch: arm64
63+
runs-on: ${{ matrix.os }}
64+
steps:
65+
- name: Code Checkout
66+
uses: actions/checkout@v6
5867

59-
- name: Setup Gradle
60-
uses: gradle/actions/setup-gradle@v5
68+
- name: Setup GraalVM
69+
uses: graalvm/setup-graalvm@v1
6170
with:
62-
cache-read-only: false
71+
java-version: '21'
72+
distribution: 'graalvm-community'
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
cache: 'gradle'
6375

6476
- name: Generating self-signed certificate
6577
run: |
@@ -73,49 +85,86 @@ jobs:
7385
-out cert.pem \
7486
-subj "/C=US/ST=SC/L=Hometown/O=IT/emailAddress=root@localhost/CN=localhost"
7587
76-
- name: Tests & Build
88+
- name: Tests & Build Native Executable
7789
run: |
7890
./gradlew build -Dquarkus.package.jar.enabled=false \
7991
-Dquarkus.native.enabled=true \
8092
-Dquarkus.native.compression.level=5
8193
82-
- name: Login to Registry
83-
uses: docker/login-action@v3
84-
with:
85-
username: ${{ github.repository_owner }}
86-
password: ${{ secrets.DOCKER_TOKEN }}
87-
88-
- name: Docker Build & Push
89-
uses: docker/build-push-action@v6
90-
with:
91-
push: true
92-
context: .
93-
file: src/main/docker/Dockerfile.native-micro
94-
tags: |
95-
${{ github.repository }}:${{ env.VERSION }}
96-
${{ github.repository }}:${{ env.DOCKER_TAG }}
97-
98-
- name: Creating GitHub Tag
99-
uses: mathieudutour/github-tag-action@v6.2
100-
with:
101-
custom_tag: ${{ env.VERSION }}
102-
tag_prefix: ''
103-
github_token: ${{ secrets.GITHUB_TOKEN }}
104-
105-
- name: Create GitHub Release
106-
uses: ncipollo/release-action@v1
107-
with:
108-
tag: ${{ env.VERSION }}
109-
token: ${{ secrets.GITHUB_TOKEN }}
110-
111-
- name: Overwrite Coverage Theme
112-
run: |
113-
/bin/cp -rf helpers/jacoco-report/* build/jacoco-report/.
114-
/bin/cp -f README.md build/jacoco-report/.
115-
116-
- name: Publishing to GitHub Pages
117-
uses: peaceiris/actions-gh-pages@v4
94+
- name: Upload Native Binary
95+
uses: actions/upload-artifact@v4
11896
with:
119-
publish_dir: ./build/jacoco-report
120-
github_token: ${{ secrets.GITHUB_TOKEN }}
121-
cname: httpbucket.testainers.com
97+
name: native-executable-${{ matrix.arch }}
98+
path: build/*-runner
99+
if-no-files-found: error
100+
retention-days: 1
101+
102+
# - name: Setup Java
103+
# uses: actions/setup-java@v5
104+
# with:
105+
# distribution: 'adopt'
106+
# java-version: '21'
107+
#
108+
# - name: Setup Gradle
109+
# uses: gradle/actions/setup-gradle@v5
110+
# with:
111+
# cache-read-only: false
112+
#
113+
# - name: Generating self-signed certificate
114+
# run: |
115+
# openssl req \
116+
# -newkey rsa:2048 \
117+
# -new \
118+
# -nodes \
119+
# -x509 \
120+
# -days 3650 \
121+
# -keyout key.pem \
122+
# -out cert.pem \
123+
# -subj "/C=US/ST=SC/L=Hometown/O=IT/emailAddress=root@localhost/CN=localhost"
124+
#
125+
# - name: Tests & Build
126+
# run: |
127+
# ./gradlew build -Dquarkus.package.jar.enabled=false \
128+
# -Dquarkus.native.enabled=true \
129+
# -Dquarkus.native.compression.level=5
130+
#
131+
# - name: Login to Registry
132+
# uses: docker/login-action@v3
133+
# with:
134+
# username: ${{ github.repository_owner }}
135+
# password: ${{ secrets.DOCKER_TOKEN }}
136+
#
137+
# - name: Docker Build & Push
138+
# uses: docker/build-push-action@v6
139+
# with:
140+
# push: true
141+
# context: .
142+
# file: src/main/docker/Dockerfile.native-micro
143+
# tags: |
144+
# ${{ github.repository }}:${{ env.VERSION }}
145+
# ${{ github.repository }}:${{ env.DOCKER_TAG }}
146+
#
147+
# - name: Creating GitHub Tag
148+
# uses: mathieudutour/github-tag-action@v6.2
149+
# with:
150+
# custom_tag: ${{ env.VERSION }}
151+
# tag_prefix: ''
152+
# github_token: ${{ secrets.GITHUB_TOKEN }}
153+
#
154+
# - name: Create GitHub Release
155+
# uses: ncipollo/release-action@v1
156+
# with:
157+
# tag: ${{ env.VERSION }}
158+
# token: ${{ secrets.GITHUB_TOKEN }}
159+
#
160+
# - name: Overwrite Coverage Theme
161+
# run: |
162+
# /bin/cp -rf helpers/jacoco-report/* build/jacoco-report/.
163+
# /bin/cp -f README.md build/jacoco-report/.
164+
#
165+
# - name: Publishing to GitHub Pages
166+
# uses: peaceiris/actions-gh-pages@v4
167+
# with:
168+
# publish_dir: ./build/jacoco-report
169+
# github_token: ${{ secrets.GITHUB_TOKEN }}
170+
# cname: httpbucket.testainers.com

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
}
3737

3838
group = "com.testainers"
39-
version = "0.3.0"
39+
version = "0.3.1"
4040

4141
java {
4242
sourceCompatibility = JavaVersion.VERSION_21

0 commit comments

Comments
 (0)