Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/gradle-publish-2
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Jan 21, 2025
2 parents f247c08 + 6010c33 commit 79c40c5
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[bumpversion]
current_version = 1.54.1
current_version = 1.55.0
41 changes: 19 additions & 22 deletions .github/workflows/java-gradle-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ on:
required: false
type: string
default: "docker.io"
platforms:
description: "Architectures for the created image (comma separated)"
required: false
default: "linux/amd64,linux/arm64"
type: string
java-distribution:
description: "Java distribution to be installed. (Default is microsoft)"
required: false
Expand Down Expand Up @@ -105,13 +110,21 @@ jobs:
sonar-token: ${{ secrets.sonar-token }}

build-jib:
name: Build tarball image
name: Build Docker image
runs-on: ubuntu-22.04
needs: build-and-test

steps:
- name: Build tarball image
uses: bakdata/ci-templates/actions/[email protected]
- name: Login into docker
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker-registry }}
username: ${{ secrets.docker-username }}
password: ${{ secrets.docker-password }}

- name: Jib build
id: build-image
uses: bakdata/ci-templates/actions/[email protected]
with:
java-distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}
Expand All @@ -120,6 +133,8 @@ jobs:
gradle-cache-read-only: true
gradle-refresh-dependencies: ${{ inputs.gradle-refresh-dependencies }}
working-directory: ${{ inputs.working-directory }}
repository: ${{ inputs.docker-registry }}/${{ inputs.docker-publisher }}
platforms: ${{ inputs.platforms }}

publish:
name: Publish
Expand All @@ -143,29 +158,11 @@ jobs:
gradle-refresh-dependencies: ${{ inputs.gradle-refresh-dependencies }}
working-directory: ${{ inputs.working-directory }}

publish-jib-image:
name: Publish tarball image
runs-on: ubuntu-22.04
needs: build-jib

steps:
- name: Login into docker
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker-registry }}
username: ${{ secrets.docker-username }}
password: ${{ secrets.docker-password }}
- name: Publish tarball image
uses: bakdata/ci-templates/actions/[email protected]
with:
docker-registry: ${{ inputs.docker-registry }}
image-namespace: ${{ inputs.docker-publisher }}

release:
name: Create Github release
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-22.04
needs: [publish, publish-jib-image]
needs: [publish, build-jib]

steps:
- name: Release on Github
Expand Down
27 changes: 13 additions & 14 deletions actions/java-gradle-build-jib/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ description: "Build Multi-Platform image using Gradle"
outputs:
image-tag:
description: "The tag of the docker image."
value: ${{ steps.meta.outputs.tags }}
value: ${{ steps.tag.outputs.name }}

inputs:
platforms:
description: "Architectures for the created image (comma separated)"
required: false
default: "linux/amd64,linux/arm64"
type: string
image-name:
description: "Name of Docker image."
repository:
description: "The repository to push the image to"
required: false
default: "${{ github.event.repository.name }}"
full-image-name:
description: "Full name of image (registry/image). The image should be provided without a tag."
required: true
allow-insecure-registries:
description: "Whether to allow insecure registries or not. (Default is false)"
required: false
Expand Down Expand Up @@ -61,9 +57,6 @@ inputs:
description: "Whether the Git checkout action should resolve LFS files or not. (Default is false)"
required: false
default: "false"
subproject:
description: "The Gradle subproject for which the image should be built (If not specified, an image for the root project will be built)"
required: false
runs:
using: "composite"
steps:
Expand All @@ -85,22 +78,28 @@ runs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image-name }}
images: ${{ github.event.repository.name }}
tags: |
event=tag,type=semver,pattern={{version}}
event=push,type=raw,value=pipeline-${{ github.run_id }}-git-{{sha}},enable=${{ github.ref_type != 'tag' }}
flavor: |
latest=false
- name: Create tag output
id: tag
run: echo "name=$(echo ${{ steps.meta.outputs.tags }} | sed 's/.*:\(.*\)/\1/')" >> "$GITHUB_OUTPUT"
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Build Docker image
run: |
./gradlew ${{ inputs.subproject && format('{0}:', inputs.subproject) || '' }}jib \
./gradlew jib \
--info --stacktrace \
--image=${{ inputs.image-name }} \
-Djib.from.platforms=${{ inputs.platforms }} \
${{ inputs.jib-from-image && format('-Djib.from.image={0}', inputs.jib-from-image) || '' }} \
${{ inputs.class && format('-Djib.container.mainClass={0}', inputs.class) || '' }} \
-Djib.to.image=${{ inputs.full-image-name }}$(echo ${{ steps.meta.outputs.tags }} | sed 's/.*\(:.*\)/\1/') \
${{ inputs.repository && format('-DjibImage.repository={0}', inputs.repository) || '' }} \
-DjibImage.tag=${{ steps.tag.outputs.name }} \
$([[ "${{ github.ref_type }}" == "tag" ]] && echo "-Djib.to.tags=latest") \
${{ inputs.gradle-refresh-dependencies == 'true' && '--refresh-dependencies' || '' }} \
${{ inputs.allow-insecure-registries == 'true' && '-Djib.allowInsecureRegistries=true' || '' }}
Expand Down
4 changes: 1 addition & 3 deletions docs/actions/java-gradle-build-jib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@
| allow-insecure-registries | string | false | `"false"` | Whether to allow insecure registries or not. (Default is false) |
| class | string | false | | The entrypoint class to be used for the image |
| download-lfs-files | string | false | `"false"` | Whether the Git checkout action should resolve LFS files or not. (Default is false) |
| full-image-name | string | true | | Full name of image (registry/image). The image should be provided without a tag. |
| gradle-cache | string | false | `"true"` | Whether Gradle caching is enabled or not. (Default is true) |
| gradle-cache-read-only | string | false | `"${{ github.event.repository != null && github.ref_name != github.event.repository.default_branch }}"` | Whether Gradle caching should be read-only. By default this value is 'false' for workflows on the GitHub default branch and 'true' for workflows on other branches. |
| gradle-refresh-dependencies | string | false | `"false"` | Whether Gradle should refresh dependencies. (Default is false) |
| gradle-version | string | false | `"wrapper"` | Gradle version to be installed. (Default is wrapper) |
| image-name | string | false | `"${{ github.event.repository.name }}"` | Name of Docker image. |
| java-distribution | string | false | `"microsoft"` | Java distribution to be installed. (Default is microsoft) |
| java-version | string | false | `"11"` | Java version to be installed. (Default is 11) |
| jib-from-image | string | false | | The Jib base image to use |
| platforms | string | false | `"linux/amd64,linux/arm64"` | Architectures for the created image (comma separated) |
| subproject | string | false | | The Gradle subproject for which the image should be built (If not specified, an image for the root project will be built) |
| repository | string | false | | The repository to push the image to |
| working-directory | string | false | `"."` | Working directory of your Gradle artifacts. (Default is .) |

<!-- AUTO-DOC-INPUT:END -->
Expand Down
23 changes: 12 additions & 11 deletions docs/workflows/java-gradle-docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,18 @@ jobs:
<!-- AUTO-DOC-INPUT:START - Do not remove or modify this section -->
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| --------------------------- | ------- | -------- | ------------- | ------------------------------------------------------------------------------------------------- |
| docker-publisher | string | true | | Publisher to prefix Docker image. |
| docker-registry | string | false | `"docker.io"` | Host where the image should be pushed to. |
| gradle-cache | boolean | false | `true` | Whether Gradle caching is enabled or not. (Default is true) |
| gradle-cache-read-only | boolean | false | `false` | Whether Gradle caching should be read-only. Only used for build and test jobs. (Default is false) |
| gradle-refresh-dependencies | boolean | false | `false` | Whether Gradle should refresh dependencies. (Default is false) |
| gradle-version | string | false | `"wrapper"` | Gradle version to be installed. (Default is wrapper) |
| java-distribution | string | false | `"microsoft"` | Java distribution to be installed. (Default is microsoft) |
| java-version | string | false | `"11"` | Java version to be installed. (Default is 11) |
| working-directory | string | false | `"."` | Working directory of your Gradle artifacts. (Default is .) |
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
| --------------------------- | ------- | -------- | --------------------------- | ------------------------------------------------------------------------------------------------- |
| docker-publisher | string | true | | Publisher to prefix Docker image. |
| docker-registry | string | false | `"docker.io"` | Host where the image should be pushed to. |
| gradle-cache | boolean | false | `true` | Whether Gradle caching is enabled or not. (Default is true) |
| gradle-cache-read-only | boolean | false | `false` | Whether Gradle caching should be read-only. Only used for build and test jobs. (Default is false) |
| gradle-refresh-dependencies | boolean | false | `false` | Whether Gradle should refresh dependencies. (Default is false) |
| gradle-version | string | false | `"wrapper"` | Gradle version to be installed. (Default is wrapper) |
| java-distribution | string | false | `"microsoft"` | Java distribution to be installed. (Default is microsoft) |
| java-version | string | false | `"11"` | Java version to be installed. (Default is 11) |
| platforms | string | false | `"linux/amd64,linux/arm64"` | Architectures for the created image (comma separated) |
| working-directory | string | false | `"."` | Working directory of your Gradle artifacts. (Default is .) |

<!-- AUTO-DOC-INPUT:END -->

Expand Down

0 comments on commit 79c40c5

Please sign in to comment.