Skip to content

Commit

Permalink
Simplified getting of maven and gradle files, no need to define anymore
Browse files Browse the repository at this point in the history
Fixed gradle settings file
  • Loading branch information
Tigerpanzer02 committed Dec 28, 2022
1 parent 4cda9ec commit 2e09c57
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 64 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ jobs:
with:
github-token: ${{ secrets.github_token }}
git-committer: 'BOT'
repo-build: GRADLE
auto-version-bump: true
- name: Print Version
run: "echo 'New Version: ${{steps.bump.outputs.version}}'"
Expand All @@ -56,9 +55,6 @@ jobs:
* `git-email`: The email address each commit should be associated with. Defaults to a github provided noreply address
* `git-username`: The GitHub username each commit should be associated with. Defaults to `version-bump[github-action]`
* `git-committer`: Who should be the committer? defined git [BOT] or last committer [USER]
* `pom-path`: The path within your directory the pom.xml you intended to change is located.
* `gradle-path`: The path within your directory the build.gradle you intended to change is located.
* `repo-build`: Using MAVEN or GRADLE to bump version
* `auto-version-bump`: Should we bump the version on every commit?
* `auto-version-bump-splitter`: Version splitter for auto bump
* `auto-version-bump-suffix`: Version suffix for auto bump
Expand Down
20 changes: 0 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,6 @@ inputs:
github-token:
description: 'A GitHub auth token to be able to create the pull request'
required: true
repo-build:
description: 'Should it use MAVEN or GRADLE'
required: true
default: 'MAVEN'
pom-path:
description: 'The relative location of your pom.xml file'
required: true
default: '.'
gradle-path:
description: 'The relative location of your build.gradle file'
required: true
default: '.'
git-email:
description: 'The email address used to create the version bump commit with.'
required: true
Expand Down Expand Up @@ -78,8 +66,6 @@ runs:
- name: Output before version
id: get-before-version
shell: bash
env:
POMPATH: ${{ inputs.pom-path }}
run: echo "before-version=$(${{github.action_path}}/src/get-version.sh)" >> $GITHUB_OUTPUT

- name: Bump Version
Expand All @@ -90,9 +76,6 @@ runs:
EMAIL: ${{ inputs.git-email }}
NAME: ${{ inputs.git-username }}
COMMITTER: ${{ inputs.git-committer }}
REPO_BUILD: ${{ inputs.repo-build }}
POMPATH: ${{ inputs.pom-path }}
GRADLEPATH: ${{ inputs.gradle-path }}
AUTO: ${{ inputs.auto-version-bump }}
AUTO_SPLITTER: ${{ inputs.auto-version-bump-splitter }}
AUTO_SUFFIX: ${{ inputs.auto-version-bump-suffix }}
Expand All @@ -105,9 +88,6 @@ runs:
id: get-outputs
shell: bash
env:
REPO_BUILD: ${{ inputs.repo-build }}
POMPATH: ${{ inputs.pom-path }}
GRADLEPATH: ${{ inputs.gradle-path }}
BEFORE_VERSION: ${{ steps.get-outputs.outputs.version }}
run: |
echo "version=$(${{github.action_path}}/src/get-version.sh)" >> $GITHUB_OUTPUT
Expand Down
3 changes: 1 addition & 2 deletions examples/gradle/deploy-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ jobs:
run: chmod +x gradlew
- name: Bump Version
id: bump
uses: Plugily-Projects/version-bump-action@v7
uses: Plugily-Projects/version-bump-action@v8
with:
github-token: ${{ secrets.github_token }}
repo-build: GRADLE
auto-version-bump: true
git-committer: 'BOT'
- name: Print Version
Expand Down
3 changes: 1 addition & 2 deletions examples/gradle/deploy-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ jobs:
run: chmod +x gradlew
- name: Bump Version
id: bump
uses: Plugily-Projects/version-bump-action@v7
uses: Plugily-Projects/version-bump-action@v8
with:
github-token: ${{ secrets.github_token }}
repo-build: GRADLE
auto-version-bump: false
auto-version-bump-release: true
git-committer: 'BOT'
Expand Down
3 changes: 1 addition & 2 deletions examples/maven/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ jobs:

- name: Bump Version
id: bump
uses: Plugily-Projects/maven-version-bump-action@v7
uses: Plugily-Projects/maven-version-bump-action@v8
with:
github-token: ${{ secrets.github_token }}
repo-build: MAVEN
auto-version-bump: true
git-committer: 'BOT'
- uses: actions/cache@v2
Expand Down
10 changes: 3 additions & 7 deletions src/get-version.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/sh

if [ "${REPO_BUILD}" = "MAVEN" ]; then
cd $POMPATH && mvn help:evaluate -Dexpression=project.version -q -DforceStdout
if [ -f ./pom.xml ] ; then
mvn help:evaluate -Dexpression=project.version -q -DforceStdout
else
BUILD_FILE=$GRADLEPATH/build.gradle
if [ ! -f "$BUILD_FILE" ]; then
BUILD_FILE=$GRADLEPATH/build.gradle.kts
fi
"$GRADLEPATH"/gradlew properties --no-daemon --console=plain -q --build-file "$BUILD_FILE" | grep "^version:" | awk '{printf $2}'
./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}'
fi
46 changes: 19 additions & 27 deletions src/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,35 @@ elif [[ "${AUTO}" == "true" ]]; then
BUMP_MODE="auto"
fi

if [ "${REPO_BUILD}" = "GRADLE" ]; then
BUILD_FILE=$GRADLEPATH/build.gradle
TYPE=GROOVY
if [ ! -f "$BUILD_FILE" ]; then
BUILD_FILE=$GRADLEPATH/build.gradle.kts
TYPE=KOTLIN
if [ -f ./pom.xml ]; then
REPO_SYSTEM=MAVEN
BUILD_FILE=./pom.xml
else
REPO_SYSTEM=GRADLE
if [ -f gradle.properties ] && grep -E -q "version=${CURRENT_VERSION}" gradle.properties; then
BUILD_FILE=./gradle.properties
elif [ -f ./build.gradle ]; then
BUILD_FILE=./build.gradle
elif [ -f ./build.gradle.kts ]; then
BUILD_FILE=./build.gradle.kts
fi
fi

if [[ "${BUMP_MODE}" == "none" ]]; then
echo "No matching commit tags found."
if [ "${REPO_BUILD}" = "MAVEN" ]; then
echo "pom.xml at" $POMPATH "will remain at" $OLD_VERSION
else
echo "build.gradle at" $GRADLEPATH "will remain at" $OLD_VERSION
fi

echo "No matching commit tags found.
Version will remain at" $OLD_VERSION
else
echo $BUMP_MODE "version bump detected"
bump $BUMP_MODE $OLD_VERSION
echo "version will be bumped from" $OLD_VERSION "to" $NEW_VERSION
REPO="https://$GITHUB_ACTOR:$TOKEN@github.com/$GITHUB_REPOSITORY.git"
if [ "${REPO_BUILD}" = "MAVEN" ]; then
echo "pom.xml at" $POMPATH "will be bumped from" $OLD_VERSION "to" $NEW_VERSION
if [ "${REPO_SYSTEM}" = "MAVEN" ]; then
mvn -q versions:set -DnewVersion="${NEW_VERSION}"
git add $POMPATH/pom.xml
git commit -m "Bump pom.xml from $OLD_VERSION to $NEW_VERSION"
else
echo "build.gradle at " $GRADLEPATH " will be bumped from" $OLD_VERSION "to" $NEW_VERSION
if [ "${TYPE}" == "GROOVY" ]; then
sed -i "s/$OLD_VERSION/$NEW_VERSION/" $BUILD_FILE
elif [ "${TYPE}" == "KOTLIN" ]; then
sed -i "s/version = \"$OLD_VERSION\"/version = \"$NEW_VERSION\"/" $BUILD_FILE
fi
git add $BUILD_FILE
git commit -m "Bump build.gradle from $OLD_VERSION to $NEW_VERSION"
elif [ "${REPO_SYSTEM}" = "GRADLE" ]; then
sed -i "s/\(version *= *['\"]*\)${OLD_VERSION}\(['\"]*\)/\1${NEW_VERSION}\2/" ${BUILD_FILE}
fi

git add $BUILD_FILE
git commit -m "Bump version from $OLD_VERSION to $NEW_VERSION"
if [[ "${BUMP_MODE}" == "auto" ]] && [[ "${AUTO_RELEASE}" == "false" ]]; then
echo "Doing no new tag for this bump because its disabled for auto mode"
git push $REPO
Expand Down

0 comments on commit 2e09c57

Please sign in to comment.