Skip to content

Commit

Permalink
Clean code and revert changes in the build action
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKora committed Sep 22, 2023
1 parent 57854f7 commit 19cb784
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 78 deletions.
100 changes: 23 additions & 77 deletions actions/java-gradle-build/action.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
name: "Release Java artifacts"
description: "Release Java Gradle artifacts on Github"
name: "Build Java artifacts"
description: "Build Java artifacts using Gradle"

inputs:
github-email:
description: "GitHub email for requesting changes from API."
required: true
github-token:
description: "GitHub token for requesting changes from API."
required: true
github-username:
description: "GitHub username for requesting changes from API."
required: true
release-type:
description: "Scope of the release"
required: true

changelog-file:
description: "Path to the changelog file"
required: false
default: "CHANGELOG.md"
gradle-cache:
description: "Whether Gradle caching is enabled or not. (Default is true)"
required: false
default: true
gradle-version:
description: "Gradle version to be installed. (Default is wrapper)"
build-artifact-name:
description: "Artifact name that is used for uploading build artifacts, see https://github.com/actions/upload-artifact (Default is build-artifact)."
required: false
default: "wrapper"
default: "build-artifact"
java-distribution:
description: "Java distribution to be installed. (Default is microsoft)"
required: false
Expand All @@ -35,36 +14,23 @@ inputs:
description: "Java version to be installed. (Default is 11)"
required: false
default: "11"
gradle-version:
description: "Gradle version to be installed. (Default is wrapper)"
required: false
default: "wrapper"
gradle-cache:
description: "Whether Gradle caching is enabled or not. (Default is true)"
required: false
default: true
working-directory:
description: "Working directory of your Gradle 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 Gradle with version ${{ inputs.gradle-version }}
uses: bakdata/ci-templates/actions/[email protected]
Expand All @@ -74,39 +40,19 @@ runs:
gradle-version: ${{ inputs.gradle-version }}
gradle-cache: ${{ inputs.gradle-cache }}

- name: Bump version
id: evaluate-version
run: |
old_version=$(./gradlew properties -q | grep "^version:" | awk '{print $2}' | tr -d '[:space:]' | xargs)
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"
- name: Compile
run: ./gradlew --info --stacktrace build -x test
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Create release
run: ./gradlew release -x test -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=${{ steps.evaluate-version.outputs.release-version }} -PdisablePushToRemote=true
- name: Build jar
run: ./gradlew --info --stacktrace jar
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Create changelog
id: build-changelog
uses: bakdata/ci-templates/actions/changelog-generate@feat/gradle-release
# uses: bakdata/ci-templates/actions/[email protected]
with:
github-token: ${{ inputs.github-token }}
new-tag: ${{ steps.evaluate-version.outputs.release-version }}
changelog-file: "${{ inputs.changelog-file }}"
fetch-reviewers: "true"
fetch-release-information: "true"

- name: Commit and push changes including .bumpversion.cfg file
uses: bakdata/ci-templates/actions/[email protected]
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
ref: ${{ github.event.repository.default_branch }}
commit-message: "Bump version ${{ steps.bump-version.outputs.old-version }} → ${{ steps.bump-version.outputs.release-version }}"
github-username: ${{ inputs.github-username }}
github-email: ${{ inputs.github-email }}
github-token: ${{ inputs.github-token }}
name: ${{ inputs.build-artifact-name }}
path: ${{ inputs.working-directory }}/**/build/libs/*.jar
retention-days: 1
2 changes: 1 addition & 1 deletion actions/java-gradle-release/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ runs:
fetch-reviewers: "true"
fetch-release-information: "true"

- name: Commit and push changes including .bumpversion.cfg file
- name: Commit and push changes including the bump config file
uses: bakdata/ci-templates/actions/[email protected]
with:
ref: ${{ github.event.repository.default_branch }}
Expand Down

0 comments on commit 19cb784

Please sign in to comment.