Skip to content

Commit

Permalink
Add actions for maven builds
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp94831 committed Sep 19, 2023
1 parent 9cf8e38 commit f2bf20e
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 5 deletions.
10 changes: 5 additions & 5 deletions actions/java-maven-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ This action builds Java artifacts using Maven and uploads `.jar` files as an art

## Input Parameters

| Name | Required | Default Value | Type | Description |
| ------------------- | :------: | :------------: | :-----: | ------------------------------------------------------------------------------------------------------------- |
| java-distribution || microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version || 11 | string | Java version to be installed |
| working-directory || "." | string | Working directory of your Gradle artifacts |
| Name | Required | Default Value | Type | Description |
| ----------------- | :------: | :-----------: | :----: | -------------------------------------------------------------------------------------------------- |
| java-distribution || microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version || 11 | string | Java version to be installed |
| working-directory || "." | string | Working directory of your Maven artifacts |

## Usage

Expand Down
29 changes: 29 additions & 0 deletions actions/java-maven-release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# java-maven-release

This action releases Java Maven artifacts by createing a tag on GitHub.

## Input Parameters

| Name | Required | Default Value | Type | Description |
| ----------------- | :------: | :-----------: | :----: | -------------------------------------------------------------------------------------------------- |
| github-email || - | string | GitHub email for requesting changes from API |
| github-username || - | string | GitHub username for requesting changes from API |
| github-token || - | string | GitHub token for requesting changes from API |
| java-distribution || microsoft | string | [Java distribution](https://github.com/actions/setup-java#supported-distributions) to be installed |
| java-version || 11 | string | Java version to be installed |
| working-directory || "." | string | Working directory of your Maven artifacts |

## Usage

```yaml
steps:
- name: Release on Github
uses: bakdata/ci-templates/actions/java-maven-release@main
with:
github-email: ${{ secrets.github-email }}
github-username: ${{ secrets.github-username }}
github-token: ${{ secrets.github-token }}
java-distribution: "microsoft" # (Optional)
java-version: "11" # (Optional)
working-directory: "." # (Optional)
```
77 changes: 77 additions & 0 deletions actions/java-maven-release/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: "Release Java artifacts"
description: "Release Java Maven artifacts on Github"

inputs:
release-type:
description: "Scope of the release"
required: true
github-email:
description: "GitHub email for requesting changes from API."
required: true
github-username:
description: "GitHub username for requesting changes from API."
required: true
github-token:
description: "GitHub token for requesting changes from API."
required: true
java-distribution:
description: "Java distribution to be installed. (Default is microsoft)"
required: false
default: "microsoft"
java-version:
description: "Java version to be installed. (Default is 11)"
required: false
default: "11"
working-directory:
description: "Working directory of your Maven artifacts. (Default is .)"
required: false
default: "."

outputs:
release-version:
description: "The bumped version of your release."
value: ${{ steps.evaluate-version.outputs.release-version }}

runs:
using: "composite"
steps:
- name: Check out repository
uses: bakdata/ci-templates/actions/[email protected]
with:
fetch-depth: 0
token: ${{ inputs.github-token }}

- name: Setup git
run: |
git config user.email ${{ inputs.github-email }}
git config user.name ${{ inputs.github-username }}
shell: bash

- name: Setup semver
run: |
wget -O /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.3.0/src/semver
chmod +x /usr/local/bin/semver
shell: bash

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: ${{ inputs.java-distribution }}
java-version: ${{ inputs.java-version }}

- name: Bump version
id: evaluate-version
run: |
old_version=$(mvn -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -q)
if [[ "${{ inputs.release-type }}" == "patch" ]]; then
release_version="${old_version%-*}"
else
release_version=$(semver bump "${{ inputs.release-type }}" "${old_version}")
fi
echo "release-version=$release_version" >> "$GITHUB_OUTPUT"
shell: bash

- name: Create release
run: mvn release:prepare -B -DreleaseVersion=${{ steps.evaluate-version.outputs.release-version }} -Darguments=-DskipTests -Dscm.developer.connection="scm:git:${{ github.server_url }}/${{ github.repository }}.git"
shell: bash
working-directory: ${{ inputs.working-directory }}

0 comments on commit f2bf20e

Please sign in to comment.